Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create widgetbook for contact item #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.7"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
linagora_design_flutter:
dependency: "direct main"
description:
Expand All @@ -299,26 +323,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.15.0"
mime:
dependency: transitive
description:
Expand All @@ -331,10 +355,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
permission_handler:
dependency: "direct main"
description:
Expand Down Expand Up @@ -464,10 +488,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.2"
typed_data:
dependency: transitive
description:
Expand All @@ -484,14 +508,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
vm_service:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "14.2.4"
win32:
dependency: transitive
description:
Expand All @@ -509,5 +533,5 @@ packages:
source: hosted
version: "6.3.0"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.14.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
2 changes: 2 additions & 0 deletions lib/linagora_design_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ export 'package:linagora_design_flutter/style/list_item_style.dart';
export 'package:linagora_design_flutter/style/linagora_divider_style.dart';
export 'package:linagora_design_flutter/style/linagora_hover_style.dart';
export 'package:linagora_design_flutter/list_item/twake_inkwell.dart';
export 'package:linagora_design_flutter/twake_chat_widget/contact/contact_item_widget.dart';
export 'package:linagora_design_flutter/twake_chat_widget/contact/contact_status.dart';
172 changes: 172 additions & 0 deletions lib/twake_chat_widget/contact/contact_item_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import 'package:flutter/material.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
import 'package:linagora_design_flutter/twake_chat_widget/contact/contact_status_widget.dart';
import 'package:linagora_design_flutter/twake_chat_widget/widgets/twake_chip.dart';

typedef OnExpansionListTileTap = void Function();

class ContactItem extends StatelessWidget {
final String? avatarUrl;
final String displayName;
final bool isCurrentMatrixId;
final ContactStatus? contactStatus;
final String? matrixId;
final String? email;
final String? phoneNumber;
final TextStyle? displayNameStyle;
final TextStyle? matrixIdStyle;
final TextStyle? emailStyle;
final TextStyle? phoneNumberStyle;
final TextStyle? contactStatusStyle;

const ContactItem({
super.key,
this.avatarUrl,
required this.displayName,
this.isCurrentMatrixId = false,
this.contactStatus,
this.matrixId,
this.email,
this.phoneNumber,
this.displayNameStyle,
this.matrixIdStyle,
this.emailStyle,
this.phoneNumberStyle,
this.contactStatusStyle,
});

@override
Widget build(BuildContext context) {
return TwakeInkWell(
onTap: () {},
onLongPress: () {},
onSecondaryTapDown: (details) {},
child: TwakeListItem(
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: 8.0, top: 8.0, bottom: 8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: IgnorePointer(
child: RoundAvatar(
imageProvider:
avatarUrl != null ? NetworkImage(avatarUrl!) : null,
imageLoadingBuilder: (context, _, __) => const Center(
child: CircularProgressIndicator(
color: Colors.amber,
),
),
text: displayName,
size: 56,
linearGradientColors: const [
Color(0xFFBDF4A1),
Color(0xFF52CE64)
],
),
),
),
const SizedBox(
width: 8.0,
),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IntrinsicWidth(
child: Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: Text(
displayName,
style: displayNameStyle ??
TextStyle(
color: LinagoraSysColors.material()
.onSurface,
fontWeight: FontWeight.w600,
fontSize: 14,
letterSpacing: 0.25,
fontFamily: 'Inter',
),
overflow: TextOverflow.ellipsis,
),
),
],
),
),
if (isCurrentMatrixId) ...[
const SizedBox(width: 8.0),
TwakeChip(
text: 'Owner',
textColor: Theme.of(context).colorScheme.primary,
),
],
const SizedBox(width: 8.0),
if (contactStatus != null &&
contactStatus == ContactStatus.inactive)
ContactStatusWidget(
status: contactStatus!,
textStyle: contactStatusStyle,
),
],
),
),
if (matrixId != null &&
(email == null || phoneNumber == null))
Text(
matrixId!,
style: matrixIdStyle ??
TextStyle(
color: LinagoraRefColors.material().tertiary[30],
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.25,
fontFamily: 'Inter',
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (email != null)
Text(
email!,
style: emailStyle ??
TextStyle(
color: LinagoraRefColors.material().tertiary[30],
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.25,
fontFamily: 'Inter',
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (phoneNumber != null)
Text(
phoneNumber!,
style: phoneNumberStyle ??
TextStyle(
color: LinagoraRefColors.material().tertiary[30],
fontWeight: FontWeight.w500,
fontSize: 14,
letterSpacing: 0.25,
fontFamily: 'Inter',
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
),
);
}
}
15 changes: 15 additions & 0 deletions lib/twake_chat_widget/contact/contact_status.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
enum ContactStatus {
active,
inactive;

String get label {
switch (this) {
case ContactStatus.active:
return 'Active';
case ContactStatus.inactive:
return 'Inactive';
default:
return '';
}
}
}
47 changes: 47 additions & 0 deletions lib/twake_chat_widget/contact/contact_status_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:flutter/material.dart';
import 'package:linagora_design_flutter/colors/linagora_ref_colors.dart';
import 'package:linagora_design_flutter/twake_chat_widget/contact/contact_status.dart';

class ContactStatusWidget extends StatelessWidget {
final ContactStatus status;
final TextStyle? textStyle;

ContactStatusWidget({
super.key,
required this.status,
this.textStyle,
});

final Color? inactiveColor = LinagoraRefColors.material().neutral[60];

@override
Widget build(BuildContext context) {
return status == ContactStatus.inactive
? Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 6,
height: 6,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: inactiveColor,
),
),
Text(
" Inactive",
style: textStyle ??
Theme.of(context).textTheme.bodySmall?.copyWith(
color: inactiveColor,
),
),
],
),
)
: const SizedBox.shrink();
}
}
36 changes: 36 additions & 0 deletions lib/twake_chat_widget/widgets/twake_chip.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';

class TwakeChip extends StatelessWidget {
final String text;

final EdgeInsets paddingText;

final Color textColor;

const TwakeChip({
super.key,
required this.text,
this.paddingText =
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 4.0),
required this.textColor,
});

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
color: Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.08),
),
child: Padding(
padding: paddingText,
child: Text(
text,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: textColor,
),
),
),
);
}
}
Loading