Skip to content

Commit

Permalink
Merge branch 'develop' into um/ASC-17520/To-support-Custom-Post-Ranking
Browse files Browse the repository at this point in the history
  • Loading branch information
umareko authored Jan 4, 2024
2 parents 7995615 + 1b473f9 commit f982b5f
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/core/route/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,8 @@ class AppRoute {

static const customRanking = 'customRanking';
static const customRankingRoute = 'customRanking';

static const getCategory = 'getCategory';
static const getCategoryRoute = 'getCategory/:categoryId';

}
6 changes: 6 additions & 0 deletions lib/core/route/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -219,6 +220,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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CommunityCategoryScreen> createState() =>
_CommunityCategoryScreenState();
}

class _CommunityCategoryScreenState extends State<CommunityCategoryScreen> {
Future<AmityCommunityCategory>? _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");
}
}),
),
),
);
}
}
15 changes: 15 additions & 0 deletions lib/presentation/screen/dashboard/dashboar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ class _DashboardScreenState extends State<DashboardScreen> {
// },
// 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: () {
Expand Down

0 comments on commit f982b5f

Please sign in to comment.