-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Screen to test the get category by id
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
lib/presentation/screen/community_category/community_category_screen.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
}), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters