Skip to content

Commit

Permalink
TW-816: update new group chat info to have better UX
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn committed Oct 26, 2023
1 parent 41081b0 commit d2f9516
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 19 deletions.
139 changes: 121 additions & 18 deletions lib/pages/new_group/new_group_chat_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ class NewGroupChatInfo extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: _buildAppBar(context),
body: Padding(
padding: NewGroupChatInfoStyle.padding,
child: LayoutBuilder(
builder: (context, constraint) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height -
MediaQuery.of(context).viewInsets.bottom,
),
child: IntrinsicHeight(
body: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverToBoxAdapter(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: NewGroupChatInfoStyle.profilePadding,
Expand Down Expand Up @@ -78,17 +73,32 @@ class NewGroupChatInfo extends StatelessWidget {
const SizedBox(height: 32),
_buildGroupNameTextField(context),
const SizedBox(height: 16),
Expanded(
child: ExpansionParticipantsList(
newGroupController: newGroupController,
contactsList: contactsList,
),
_EncryptionSettingTile(
enableEncryptionNotifier:
newGroupController.enableEncryptionNotifier,
onChanged: (value) {
newGroupController.toggleEnableEncryption();
},
),
],
),
),
);
},
),
];
},
body: Padding(
padding: NewGroupChatInfoStyle.padding,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: ExpansionParticipantsList(
newGroupController: newGroupController,
contactsList: contactsList,
),
),
],
),
),
),
floatingActionButton: ValueListenableBuilder<bool>(
Expand Down Expand Up @@ -320,3 +330,96 @@ class _AvatarForWebBuilder extends StatelessWidget {
);
}
}

class _EncryptionSettingTile extends StatelessWidget {
final ValueNotifier<bool> enableEncryptionNotifier;

final ValueChanged<bool?>? onChanged;

const _EncryptionSettingTile({
required this.enableEncryptionNotifier,
this.onChanged,
});

@override
Widget build(BuildContext context) {
return Padding(
padding: NewGroupChatInfoStyle.screenPadding,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: NewGroupChatInfoStyle.topScreenPadding,
child: Icon(
Icons.lock,
),
),
const SizedBox(
width: 8.0,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: NewGroupChatInfoStyle.topScreenPadding,
child: Text(
L10n.of(context)!.enableEncryption,
style: Theme.of(context).textTheme.titleMedium,
),
),
const SizedBox(height: 4.0),
ValueListenableBuilder<bool>(
valueListenable: enableEncryptionNotifier,
builder: (context, isEnable, child) {
return Column(
children: [
Text(
L10n.of(context)!.encryptionMessage,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color: LinagoraRefColors.material().neutral[40],
),
),
AnimatedSize(
alignment: Alignment.topCenter,
duration: const Duration(milliseconds: 50),
child: isEnable
? Text(
L10n.of(context)!.encryptionWarning,
style: Theme.of(context)
.textTheme
.bodyMedium
?.copyWith(
color:
Theme.of(context).colorScheme.error,
),
)
: const SizedBox.shrink(),
),
],
);
},
),
],
),
),
const SizedBox(
width: 12,
),
ValueListenableBuilder<bool>(
valueListenable: enableEncryptionNotifier,
builder: (context, isEnable, child) {
return Checkbox(
value: isEnable,
onChanged: (value) => onChanged?.call(value),
);
},
),
],
),
);
}
}
6 changes: 6 additions & 0 deletions lib/pages/new_group/new_group_chat_info_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ class NewGroupChatInfoStyle {

static const EdgeInsetsDirectional profilePadding =
EdgeInsetsDirectional.only(top: 16.0);

static const EdgeInsetsDirectional screenPadding =
EdgeInsetsDirectional.only(start: 8.0, bottom: 8.0, end: 4.0);

static const EdgeInsetsDirectional topScreenPadding =
EdgeInsetsDirectional.only(top: 8.0);
}
2 changes: 1 addition & 1 deletion lib/pages/new_group/widget/selected_participants_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class _SelectedParticipantsListState extends State<SelectedParticipantsList> {
),
],
),
)
),
],
);
},
Expand Down

0 comments on commit d2f9516

Please sign in to comment.