Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Screen to test the get category by id #208

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/core/route/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,7 @@ class AppRoute {

static const viewStream = 'viewStream';
static const viewStreamRoute = 'viewStream';

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 @@ -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,
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 @@ -190,6 +190,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
Loading