diff --git a/lib/core/route/app_route.dart b/lib/core/route/app_route.dart index 6ae121b..74876bb 100644 --- a/lib/core/route/app_route.dart +++ b/lib/core/route/app_route.dart @@ -137,4 +137,7 @@ class AppRoute { static const viewStream = 'viewStream'; static const viewStreamRoute = 'viewStream'; + + static const getCategory = 'getCategory'; + static const getCategoryRoute = 'getCategory/:categoryId'; } diff --git a/lib/core/route/app_router.dart b/lib/core/route/app_router.dart index 6412f50..9c5d772 100644 --- a/lib/core/route/app_router.dart +++ b/lib/core/route/app_router.dart @@ -9,6 +9,7 @@ import 'package:flutter_social_sample_app/presentation/screen/channel_update/cha import 'package:flutter_social_sample_app/presentation/screen/chat/chat_screen.dart'; import 'package:flutter_social_sample_app/presentation/screen/comment_query/comment_query_screen.dart'; import 'package:flutter_social_sample_app/presentation/screen/comment_query_reply/comment_query_reply_screen.dart'; +import 'package:flutter_social_sample_app/presentation/screen/community_category/community_category_screen.dart'; import 'package:flutter_social_sample_app/presentation/screen/community_create/community_create_screen.dart'; import 'package:flutter_social_sample_app/presentation/screen/community_feed/community_feed_screen.dart'; import 'package:flutter_social_sample_app/presentation/screen/community_in_review_post_list/community_in_review_post_list_screen.dart'; @@ -213,6 +214,11 @@ class AppRouter { path: AppRoute.postDetailRoute, builder: (context, state) => PostDetailScreen(postId: state.params['postId']!), ), + GoRoute( + name: AppRoute.getCategory, + path: AppRoute.getCategoryRoute, + builder: (context, state) => CommunityCategoryScreen(categoryId: state.params['categoryId']!), + ), GoRoute( name: AppRoute.createPollPost, path: AppRoute.createPollPostRoute, diff --git a/lib/presentation/screen/community_category/community_category_screen.dart b/lib/presentation/screen/community_category/community_category_screen.dart new file mode 100644 index 0000000..d0e0d71 --- /dev/null +++ b/lib/presentation/screen/community_category/community_category_screen.dart @@ -0,0 +1,60 @@ +import 'package:amity_sdk/amity_sdk.dart'; +import 'package:flutter/material.dart'; + +class CommunityCategoryScreen extends StatefulWidget { + final String categoryId; + const CommunityCategoryScreen({super.key, required this.categoryId}); + + @override + State createState() => + _CommunityCategoryScreenState(); +} + +class _CommunityCategoryScreenState extends State { + Future? _future; + @override + void initState() { + _future = AmitySocialClient.newCommunityRepository() + .getCategory(widget.categoryId); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Community Catergory'), + ), + body: SafeArea( + child: FutureBuilder( + future: _future, + builder: ((context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else { + if (snapshot.hasData) { + var category = snapshot.data as AmityCommunityCategory; + return ListTile( + leading: category.avatarId != null + ? Image.network( + category.avatar!.fileUrl!, + fit: BoxFit.fill, + ) + : Image.asset('assets/user_placeholder.png'), + title: Text(category.name!), + subtitle: Text(category.categoryId!), + ); + } + + if (snapshot.hasError) { + return Text("Error ${snapshot.error}"); + } + + return const Text("No Data"); + } + }), + ), + ), + ); + } +} diff --git a/lib/presentation/screen/dashboard/dashboar_screen.dart b/lib/presentation/screen/dashboard/dashboar_screen.dart index 359bbfe..48b5632 100644 --- a/lib/presentation/screen/dashboard/dashboar_screen.dart +++ b/lib/presentation/screen/dashboard/dashboar_screen.dart @@ -190,6 +190,21 @@ class _DashboardScreenState extends State { // }, // child: const Text('Create Community'), // ), + const SizedBox(height: 20), + TextButton( + onPressed: () { + EditTextDialog.show( + context, + hintText: 'Enter Category Id', + onPress: (value) { + GoRouter.of(context).goNamed(AppRoute.getCategory, + params: {'categoryId': value}); + }, + ); + }, + child: const Text('Get Category by Id'), + ), + const SizedBox(height: 20), TextButton( onPressed: () {