Skip to content

Commit

Permalink
Update UI for community list (#232)
Browse files Browse the repository at this point in the history
Co-authored-by: Zryte <[email protected]>
  • Loading branch information
Zryte and Zryte authored Jun 18, 2024
1 parent bfb3264 commit df4a75b
Showing 1 changed file with 130 additions and 128 deletions.
258 changes: 130 additions & 128 deletions lib/presentation/screen/community_list/community_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ class _CommunityListScreenState extends State<CommunityListScreen> {

@override
void initState() {

communityLiveCollectionInit();
super.initState();
}

void communityLiveCollectionInit() {

void communityLiveCollectionInit() {
communityLiveCollection = CommunityLiveCollection(
request: () => AmitySocialClient.newCommunityRepository()
.getCommunities()
Expand All @@ -50,7 +48,6 @@ class _CommunityListScreenState extends State<CommunityListScreen> {
.includeDeleted(_includeDelete)
.build());


communityLiveCollection.getStreamController().stream.listen((event) {
if (mounted) {
setState(() {
Expand All @@ -59,19 +56,16 @@ class _CommunityListScreenState extends State<CommunityListScreen> {
}
});

WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
communityLiveCollection.loadNext();
});

scrollcontroller.addListener(pagination);
}

void pagination() {
if ((scrollcontroller.position.pixels ==
scrollcontroller.position.maxScrollExtent) &&
communityLiveCollection.hasNextPage()) {
communityLiveCollection.loadNext();
}
scrollcontroller.position.maxScrollExtent) &&
communityLiveCollection.hasNextPage()) {
print("TriggerPagination");
communityLiveCollection.loadNext();
}
}

@override
Expand All @@ -86,141 +80,149 @@ class _CommunityListScreenState extends State<CommunityListScreen> {
onChanged: (value) {
_debouncer.run(() {
_keyboard = value;
communityLiveCollection.reset();
communityLiveCollectionInit();
});
},
decoration: const InputDecoration(hintText: 'Enter Keybaord'),
),
),
Container(
child: Row(
children: [
Container(
padding: const EdgeInsets.all(8),
child: PopupMenuButton(
itemBuilder: (context) {
return [
PopupMenuItem(
value: 1,
child: Text(AmityCommunityFilter.ALL.name),
),
PopupMenuItem(
value: 2,
child: Text(AmityCommunityFilter.MEMBER.name),
),
PopupMenuItem(
value: 3,
child: Text(AmityCommunityFilter.NOT_MEMBER.name),
)
];
},
child: const Icon(
Icons.filter_alt_rounded,
size: 18,
),
onSelected: (index) {
if (index == 1) {
_filter = AmityCommunityFilter.ALL;
}
if (index == 2) {
_filter = AmityCommunityFilter.MEMBER;
}
if (index == 3) {
_filter = AmityCommunityFilter.NOT_MEMBER;
}

communityLiveCollection.reset();
communityLiveCollectionInit();
},
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
child: PopupMenuButton(
itemBuilder: (context) {
return [
PopupMenuItem(
value: 1,
child: Text(AmityCommunityFilter.ALL.name),
),
PopupMenuItem(
value: 2,
child: Text(AmityCommunityFilter.MEMBER.name),
),
PopupMenuItem(
value: 3,
child: Text(AmityCommunityFilter.NOT_MEMBER.name),
)
];
},
child: const Icon(
Icons.filter_alt_rounded,
size: 18,
),
onSelected: (index) {
if (index == 1) {
_filter = AmityCommunityFilter.ALL;
}
if (index == 2) {
_filter = AmityCommunityFilter.MEMBER;
}
if (index == 3) {
_filter = AmityCommunityFilter.NOT_MEMBER;
}
},
),
Container(
padding: const EdgeInsets.all(8),
child: PopupMenuButton(
itemBuilder: (context) {
return [
PopupMenuItem(

child: Text(AmityCommunitySortOption.DISPLAY_NAME.name),
value: 1,
),
PopupMenuItem(
child: Text(AmityCommunitySortOption.FIRST_CREATED.name),
value: 2,
),
PopupMenuItem(
child: Text(AmityCommunitySortOption.LAST_CREATED.name),
value: 3,
)
];
},
child: const Icon(
Icons.sort_rounded,
size: 18,
),
onSelected: (index) {
if (index == 1) {
_sort = AmityCommunitySortOption.DISPLAY_NAME;
}
if (index == 2) {
_sort = AmityCommunitySortOption.FIRST_CREATED;
}
if (index == 3) {
_sort = AmityCommunitySortOption.LAST_CREATED;
}
communityLiveCollection.reset();
communityLiveCollectionInit();
},
),
Container(
padding: const EdgeInsets.all(8),
child: PopupMenuButton(
itemBuilder: (context) {
return [
PopupMenuItem(
value: 1,
child:
Text(AmityCommunitySortOption.DISPLAY_NAME.name),
),
PopupMenuItem(
value: 2,
child:
Text(AmityCommunitySortOption.FIRST_CREATED.name),
),
PopupMenuItem(
value: 3,
child:
Text(AmityCommunitySortOption.LAST_CREATED.name),
)
];
},
child: const Icon(
Icons.sort_rounded,
size: 18,
),
onSelected: (index) {
if (index == 1) {
_sort = AmityCommunitySortOption.DISPLAY_NAME;
}
if (index == 2) {
_sort = AmityCommunitySortOption.FIRST_CREATED;
}
if (index == 3) {
_sort = AmityCommunitySortOption.LAST_CREATED;
}
},
),
),
Container(
padding: const EdgeInsets.all(8),
child: InkWell(
child: const Icon(Icons.tag, size: 18),
onTap: () {
EditTextDialog.show(context,
title: 'Enter tags, separate by comma',
hintText: 'type tags here', onPress: (value) {
if (value.isNotEmpty) {
_tags = value.trim().split(',');
} else {
_tags = null;
}
});
},
),
Container(
padding: const EdgeInsets.all(8),
child: InkWell(
child: const Icon(Icons.tag, size: 18),
onTap: () {
EditTextDialog.show(context, title: 'Enter tags, separate by comma', hintText: 'type tags here',
onPress: (value) {
if (value.isNotEmpty) {
_tags = value.trim().split(',');
} else {
_tags = null;
}
),
Container(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Checkbox(
value: _includeDelete,
onChanged: (value) {
setState(() {
_includeDelete = (value ?? false);
});
},
),
const Text('Include Delete')
],
),
),
Container(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
onPressed: () {
communityLiveCollection.reset();
communityLiveCollectionInit();
});
},
),
),
Container(
padding: const EdgeInsets.all(8),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Checkbox(
value: _includeDelete,
onChanged: (value) {
setState(() {
_includeDelete = (value ?? false);
communityLiveCollection.reset();

communityLiveCollectionInit();
});
},
communityLiveCollection.loadNext();
},
child: const Text(
"Query",
),
const Text('Include Delete')
],
),
)
],
),
)
],
),
)
],
),
Expanded(
child: amityCommunities.isNotEmpty
? RefreshIndicator(
onRefresh: () async {
communityLiveCollection.reset();
communityLiveCollectionInit();
communityLiveCollection.loadNext();
},
child: ListView.builder(
controller: scrollcontroller,
Expand Down

0 comments on commit df4a75b

Please sign in to comment.