Skip to content

Commit

Permalink
TW-2042 Update contact list item
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim committed Sep 30, 2024
1 parent b8c2f51 commit 99f30bc
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 110 deletions.
2 changes: 1 addition & 1 deletion lib/pages/contacts_tab/contacts_tab_view_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ContactsTabViewStyle {
static const double loadingSpacer = 16;
static const double avatarSize = 48.0;

static const searchItemsHoverRadius = BorderRadius.all(Radius.circular(12));
static const searchItemsHoverRadius = BorderRadius.all(Radius.circular(4));
static const invitefriendContainterPadding = EdgeInsets.all(8);
static const invitefriendContainterLeadingIconPadding = EdgeInsets.all(8);
static const leadingIconDimension = 24.0;
Expand Down
205 changes: 116 additions & 89 deletions lib/pages/new_private_chat/widget/expansion_contact_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import 'package:flutter/material.dart';
import 'package:linagora_design_flutter/colors/linagora_ref_colors.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:fluffychat/utils/string_extension.dart';
import 'package:linagora_design_flutter/colors/linagora_state_layer.dart';
import 'package:linagora_design_flutter/colors/linagora_sys_colors.dart';
import 'package:linagora_design_flutter/style/linagora_text_style.dart';
import 'package:matrix/matrix.dart';

typedef OnExpansionListTileTap = void Function();
Expand All @@ -26,102 +29,126 @@ class ExpansionContactListTile extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0, bottom: 12.0),
child: FutureBuilder<Profile?>(
key: contact.matrixId != null ? Key(contact.matrixId!) : null,
future:
contact.status == ContactStatus.active ? getProfile(context) : null,
builder: (context, snapshot) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IgnorePointer(
child: Avatar(
mxContent: snapshot.data?.avatarUrl,
name: contact.displayName,
return Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: LinagoraStateLayer(LinagoraSysColors.material().surfaceTint)
.opacityLayer3,
width: 1,
),
),
),
child: Padding(
padding: const EdgeInsets.only(left: 8.0, top: 8.0, bottom: 8.0),
child: FutureBuilder<Profile?>(
key: contact.matrixId != null ? Key(contact.matrixId!) : null,
future: contact.status == ContactStatus.active
? getProfile(context)
: null,
builder: (context, snapshot) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IgnorePointer(
child: Avatar(
mxContent: snapshot.data?.avatarUrl,
name: contact.displayName,
),
),
const SizedBox(
width: 12.0,
),
),
const SizedBox(
width: 12.0,
),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IntrinsicWidth(
child: Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: BuildDisplayName(
profileDisplayName:
snapshot.data?.displayName,
contactDisplayName: contact.displayName,
highlightKeyword: highlightKeyword,
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface,
),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
IntrinsicWidth(
child: Row(
children: [
Expanded(
child: Row(
children: [
Flexible(
child: BuildDisplayName(
profileDisplayName:
snapshot.data?.displayName,
contactDisplayName: contact.displayName,
highlightKeyword: highlightKeyword,
style: LinagoraTextStyle.material()
.bodyMedium2
.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface,
),
),
),
),
],
],
),
),
),
if (contact.matrixId != null &&
contact.matrixId!.isCurrentMatrixId(context)) ...[
if (contact.matrixId != null &&
contact.matrixId!
.isCurrentMatrixId(context)) ...[
const SizedBox(width: 8.0),
TwakeChip(
text: L10n.of(context)!.owner,
textColor:
Theme.of(context).colorScheme.primary,
),
],
const SizedBox(width: 8.0),
TwakeChip(
text: L10n.of(context)!.owner,
textColor: Theme.of(context).colorScheme.primary,
),
if (contact.status != null &&
contact.status == ContactStatus.inactive)
ContactStatusWidget(
status: contact.status!,
),
],
const SizedBox(width: 8.0),
if (contact.status != null &&
contact.status == ContactStatus.inactive)
ContactStatusWidget(
status: contact.status!,
),
],
),
),
if (contact.matrixId != null)
HighlightText(
text: contact.matrixId!,
searchWord: highlightKeyword,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraRefColors.material().neutral[60],
),
),
if (contact.email != null)
HighlightText(
text: contact.email!,
searchWord: highlightKeyword,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraRefColors.material().neutral[60],
),
),
if (contact.phoneNumber != null)
HighlightText(
text: contact.phoneNumber!,
searchWord: highlightKeyword,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: LinagoraRefColors.material().neutral[60],
),
),
),
],
if (contact.matrixId != null &&
(contact.email == null ||
contact.phoneNumber == null))
HighlightText(
text: contact.matrixId!,
searchWord: highlightKeyword,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: LinagoraRefColors.material().neutral[60],
),
),
if (contact.email != null)
HighlightText(
text: contact.email!,
searchWord: highlightKeyword,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: LinagoraRefColors.material().neutral[60],
),
),
if (contact.phoneNumber != null)
HighlightText(
text: contact.phoneNumber!,
searchWord: highlightKeyword,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: LinagoraRefColors.material().neutral[60],
),
),
],
),
),
),
],
);
},
],
);
},
),
),
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/highlight_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HighlightText extends StatelessWidget {
maxLines: maxLines,
overflow: overflow,
softWrap: softWrap,
style: Theme.of(context).textTheme.bodyMedium,
);
}
}
24 changes: 4 additions & 20 deletions lib/widgets/sliver_expandable_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:fluffychat/pages/chat_list/chat_list_body_view.dart';
import 'package:fluffychat/utils/extension/value_notifier_extension.dart';
import 'package:flutter/material.dart';

class SliverExpandableList extends StatefulWidget {
Expand All @@ -19,26 +17,12 @@ class SliverExpandableList extends StatefulWidget {
}

class _SliverExpandableListState extends State<SliverExpandableList> {
final isExpandedNotifier = ValueNotifier<bool>(true);

@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: isExpandedNotifier,
builder: (context, isExpanded, child) {
return SliverList.builder(
itemCount: (isExpanded ? widget.itemCount : 0) + 1,
itemBuilder: (context, index) {
if (index == 0) {
return ExpandableTitleBuilder(
title: widget.title,
isExpanded: isExpanded,
onTap: isExpandedNotifier.toggle,
);
}
return widget.itemBuilder(context, index - 1);
},
);
return SliverList.builder(
itemCount: widget.itemCount,
itemBuilder: (context, index) {
return widget.itemBuilder(context, index);
},
);
}
Expand Down

0 comments on commit 99f30bc

Please sign in to comment.