Skip to content

Commit

Permalink
feat: remove scrollable view in new group chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian KOUNE committed Jul 13, 2023
1 parent a4086ba commit 786d8fc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 62 deletions.
20 changes: 0 additions & 20 deletions lib/pages/new_group/new_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class NewGroupController extends State<NewGroup>
final fetchContactsController = FetchContactsController();
final contactStreamController = StreamController<Either<Failure, GetContactsSuccess>>();
final groupNameTextEditingController = TextEditingController();
final groupchatInfoScrollController = ScrollController();

final selectedContactsMapNotifier = SelectedContactsMapChangeNotifier();
final haveGroupNameNotifier = ValueNotifier(false);
Expand All @@ -50,7 +49,6 @@ class NewGroupController extends State<NewGroup>
listenSearchContacts();
listenGroupNameChanged();
fetchContactsController.fetchCurrentTomContacts();
listenForGroupchatInfoScrollController();
fetchContactsController.listenForScrollChanged(fetchContactsController: fetchContactsController);
searchContactsController.onSearchKeywordChanged = (searchKey) {
disableLoadMoreInSearch();
Expand All @@ -73,16 +71,6 @@ class NewGroupController extends State<NewGroup>
haveGroupNameNotifier.dispose();
}

void listenForGroupchatInfoScrollController() {
groupchatInfoScrollController.addListener(() {
if (groupchatInfoScrollController.offset > maxScrollOffsetAllowedInPixel) {
groupchatInfoScrollController.jumpTo(
maxScrollOffsetAllowedInPixel,
);
}
});
}

void listenContactsStartList() {
fetchContactsController.streamController.stream.listen((event) {
Logs().d('NewGroupController::fetchContacts() - event: $event');
Expand Down Expand Up @@ -143,14 +131,6 @@ class NewGroupController extends State<NewGroup>
);
}

void autoScrollWhenExpandParticipants() {
groupchatInfoScrollController.animateTo(
MediaQuery.of(context).size.height,
duration: const Duration(milliseconds: 800),
curve: Curves.easeIn,
);
}

@override
Widget build(BuildContext context) => NewGroupView(this);
}
72 changes: 34 additions & 38 deletions lib/pages/new_group/new_group_chat_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,43 @@ class NewGroupChatInfo extends StatelessWidget {
appBar: _buildAppBar(context),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: SingleChildScrollView(
physics: const ClampingScrollPhysics(),
controller: newGroupController.groupchatInfoScrollController,
child: LayoutBuilder(
builder: (context, constraint) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height - MediaQuery.of(context).viewInsets.bottom
),
child: IntrinsicHeight(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: _buildChangeProfileWidget(context)),
const SizedBox(height: 16.0),
Text(L10n.of(context)!.addAPhoto,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
child: LayoutBuilder(
builder: (context, constraint) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height - MediaQuery.of(context).viewInsets.bottom
),
child: IntrinsicHeight(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: _buildChangeProfileWidget(context)),
const SizedBox(height: 16.0),
Text(L10n.of(context)!.addAPhoto,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
Text(L10n.of(context)!.maxImageSize(5),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: LinagoraRefColors.material().neutral[40],
)),
const SizedBox(height: 32),
_buildGroupNameTextFieid(context),
const SizedBox(height: 16),
Expanded(
child: ExpansionParticipantsList(
newGroupController: newGroupController,
contactsList: contactsList,
),
),
Text(L10n.of(context)!.maxImageSize(5),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: LinagoraRefColors.material().neutral[40],
)),
const SizedBox(height: 32),
_buildGroupNameTextFieid(context),
const SizedBox(height: 16),
Expanded(
child: ExpansionParticipantsList(
newGroupController: newGroupController,
contactsList: contactsList,
),
],
),
),
],
),
);
}
),
),
);
}
),
),
floatingActionButton: ValueListenableBuilder<bool>(
Expand Down
3 changes: 0 additions & 3 deletions lib/pages/new_group/widget/expansion_participants_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ class _ExpansionParticipantsListState extends State<ExpansionParticipantsList> {
void toggleExpansionList() {
setState(() {
isExpanded = !isExpanded;
if (isExpanded) {
widget.newGroupController.autoScrollWhenExpandParticipants();
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LoadingContactWidget extends StatelessWidget {
const SizedBox(height: 16.0,),
const CircularProgressIndicator(),
const SizedBox(height: 16.0,),
Text(L10n.of(context)!.loadingContacts,
Text(L10n.of(context)!.loadingContacts,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.secondary,
),),
Expand Down

0 comments on commit 786d8fc

Please sign in to comment.