From f482fc8cb5f7596867e68ebdd86300c147dd1030 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 5 Sep 2024 20:18:13 +0900 Subject: [PATCH 1/8] =?UTF-8?q?M3-334=20Feat=20:=20Community=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/community.dart | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/models/community.dart diff --git a/lib/models/community.dart b/lib/models/community.dart new file mode 100644 index 00000000..bdd5980a --- /dev/null +++ b/lib/models/community.dart @@ -0,0 +1,39 @@ +class Community { + int communityRanking; + String name; + int communityColor; + String backgroundImageUrl; + int memberCount; + int currentPixelCount; + int accumulatePixelCount; + int maxPixelCount; + int maxRanking; + + Community({ + required this.communityRanking, + required this.name, + required this.communityColor, + required this.backgroundImageUrl, + required this.memberCount, + required this.currentPixelCount, + required this.accumulatePixelCount, + required this.maxPixelCount, + required this.maxRanking, + }); + + factory Community.fromJson(Map json) { + return Community( + communityRanking: json['communityRanking'], + name: json['name'], + communityColor: json['communityColor'] is String + ? int.parse(json['communityColor'], radix: 16) + : json['communityColor'], + backgroundImageUrl: json['backgroundImageUrl'], + memberCount: json['memberCount'], + currentPixelCount: json['currentPixelCount'], + accumulatePixelCount: json['accumulatePixelCount'], + maxPixelCount: json['maxPixelCount'], + maxRanking: json['maxRanking'], + ); + } +} From 5fb46321023e511d04f577fe84543a9a419ac822 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 5 Sep 2024 21:26:12 +0900 Subject: [PATCH 2/8] =?UTF-8?q?M3-334=20Feat=20:=20CommunityServiced?= =?UTF-8?q?=EC=9D=98=20getCommunityInfo=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/service/community_service.dart | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/service/community_service.dart diff --git a/lib/service/community_service.dart b/lib/service/community_service.dart new file mode 100644 index 00000000..b53b3ae9 --- /dev/null +++ b/lib/service/community_service.dart @@ -0,0 +1,20 @@ +import 'package:dio/dio.dart'; + +import '../models/community.dart'; +import '../utils/dio_service.dart'; + +class CommunityService { + static final CommunityService _instance = CommunityService._internal(); + final Dio dio = DioService().getDio(); + + CommunityService._internal(); + + factory CommunityService() { + return _instance; + } + + Future getCommunityInfo(int communityId) async { + var response = await dio.get('/communities/$communityId'); + return Community.fromJson(response.data['data']); + } +} From e620e59ae8491fee0764619ce2b42460e2832249 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 5 Sep 2024 21:27:02 +0900 Subject: [PATCH 3/8] =?UTF-8?q?M3-334=20Feat=20:=20=EA=B7=B8=EB=A3=B9=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=A1=9C=EB=94=A9=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/controllers/community_controller.dart | 30 +++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/controllers/community_controller.dart b/lib/controllers/community_controller.dart index 7395600c..7fee99c3 100644 --- a/lib/controllers/community_controller.dart +++ b/lib/controllers/community_controller.dart @@ -1,19 +1,22 @@ import 'package:get/get.dart'; +import '../models/community.dart'; import '../models/ranking.dart'; +import '../service/community_service.dart'; class CommunityController extends GetxController { + final CommunityService communityService = CommunityService(); final RxString name = "".obs; final RxString imageUrl = "".obs; - final RxInt memberCount = 0.obs; final RxInt communityColor = 0.obs; final RxInt communityRanking = 0.obs; final RxInt currentPixelCount = 0.obs; final RxInt accumulatePixelCount = 0.obs; final RxInt maxPixelCount = 0.obs; - final RxInt maxRankingCount = 0.obs; + final RxInt maxRanking = 0.obs; final RxBool isJoin = true.obs; + final RxBool isLoading = true.obs; final RxList members = [ Ranking(userId: 1, rank: 1, currentPixelCount: 123, nickname: "test1"), @@ -23,16 +26,17 @@ class CommunityController extends GetxController { Ranking(userId: 1, rank: 5, currentPixelCount: 123, nickname: "test5"), ].obs; - init(int groupId) { - name.value = "세종대학교"; - imageUrl.value = - "https://ground-flip-prod-storage-resized.s3.ap-northeast-2.amazonaws.com/resized-static/42166cf0-b557-42a1-a1fb-d04472ea0ac1%23%23%23622.jpg"; - memberCount.value = 3; - communityColor.value = 0xFF0DF69E; - communityRanking.value = 534; - currentPixelCount.value = 124; - accumulatePixelCount.value = 11394; - maxPixelCount.value = 945; - maxRankingCount.value = 53; + init(int communityId) async { + Community community = await communityService.getCommunityInfo(communityId); + name.value = community.name; + imageUrl.value = community.backgroundImageUrl; + memberCount.value = community.memberCount; + communityColor.value = community.communityColor; + communityRanking.value = community.communityRanking; + currentPixelCount.value = community.currentPixelCount; + accumulatePixelCount.value = community.accumulatePixelCount; + maxPixelCount.value = community.maxPixelCount; + maxRanking.value = community.maxRanking; + isLoading.value = false; } } From a33a572088cfeae121fde0b8a73bed50130f3111 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 5 Sep 2024 21:27:12 +0900 Subject: [PATCH 4/8] =?UTF-8?q?M3-334=20Feat=20:=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/screens/community_screen.dart | 192 ++++++++++++++++-------------- 1 file changed, 103 insertions(+), 89 deletions(-) diff --git a/lib/screens/community_screen.dart b/lib/screens/community_screen.dart index 0e778045..6754fb0d 100644 --- a/lib/screens/community_screen.dart +++ b/lib/screens/community_screen.dart @@ -22,103 +22,117 @@ class CommunityScreen extends StatelessWidget { @override Widget build(BuildContext context) { - final CommunityController groupController = Get.put(CommunityController()); - groupController.init(groupId); - return CustomScrollView( - slivers: [ - SliverAppBar( - expandedHeight: 350.0, - floating: false, - pinned: true, - iconTheme: IconThemeData( - color: Colors.white, + final CommunityController communityController = + Get.put(CommunityController()); + communityController.init(groupId); + + return Obx(() { + if (communityController.isLoading.value) { + return const Center( + child: CircularProgressIndicator( + color: AppColors.primary, ), - leading: isTap - ? null - : IconButton( - icon: Icon(Icons.arrow_back_ios), - onPressed: () { - Get.back(); - }, - ), - actions: [ - IconButton( - icon: SvgPicture.asset( - 'assets/images/share_icon.svg', - width: 20, + ); + } else { + return CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 350.0, + floating: false, + pinned: true, + iconTheme: IconThemeData( + color: Colors.white, ), - onPressed: () {}, - ), - ], - backgroundColor: AppColors.background, - flexibleSpace: LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - var top = constraints.biggest.height; - return FlexibleSpaceBar( - title: top <= 120 - ? Text( - groupController.name.value, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - ), - ) - : Align( - alignment: Alignment.bottomLeft, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Text( - groupController.name.value, + leading: isTap + ? null + : IconButton( + icon: Icon(Icons.arrow_back_ios), + onPressed: () { + Get.back(); + }, + ), + actions: [ + IconButton( + icon: SvgPicture.asset( + 'assets/images/share_icon.svg', + width: 20, + ), + onPressed: () {}, + ), + ], + backgroundColor: AppColors.background, + flexibleSpace: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + var top = constraints.biggest.height; + return FlexibleSpaceBar( + title: top <= 120 + ? Text( + communityController.name.value, style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, - fontSize: 20, + ), + ) + : Align( + alignment: Alignment.bottomLeft, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 10.0), + child: Text( + communityController.name.value, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 20, + ), + ), ), ), - ), - ), - background: CommunityImage( - imageUrl: groupController.imageUrl.value, - ), - collapseMode: CollapseMode.parallax, - ); - }, - ), - ), - SliverToBoxAdapter( - child: Padding( - padding: EdgeInsets.all(10), - child: Column( - children: [ - CommunityInfo( - memberCount: groupController.memberCount, - communityColor: groupController.communityColor, - weeklyRanking: groupController.communityRanking, - ), - SizedBox( - height: 20, - ), - CommunityRecord( - currentPixelCount: groupController.currentPixelCount, - accumulatePixelCount: groupController.accumulatePixelCount, - maxPixelCount: groupController.maxPixelCount, - maxRankingCount: groupController.maxRankingCount, - ), - SizedBox( - height: 20, - ), - MemberList(members: groupController.members), - SizedBox( - height: 20, - ), - CommunityActionButton( - isJoin: groupController.isJoin.value, + background: CommunityImage( + imageUrl: communityController.imageUrl.value, + ), + collapseMode: CollapseMode.parallax, + ); + }, + ), + ), + SliverToBoxAdapter( + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + children: [ + CommunityInfo( + memberCount: communityController.memberCount, + communityColor: communityController.communityColor, + weeklyRanking: communityController.communityRanking, + ), + SizedBox( + height: 20, + ), + CommunityRecord( + currentPixelCount: communityController.currentPixelCount, + accumulatePixelCount: + communityController.accumulatePixelCount, + maxPixelCount: communityController.maxPixelCount, + maxRankingCount: communityController.maxRanking, + ), + SizedBox( + height: 20, + ), + MemberList(members: communityController.members), + SizedBox( + height: 20, + ), + CommunityActionButton( + isJoin: communityController.isJoin.value, + ), + ], ), - ], + ), ), - ), - ), - ], - ); + ], + ); + } + }); } } From 741e2c8b418bb28c6d06dff4c81313d88a500a45 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 5 Sep 2024 22:08:17 +0900 Subject: [PATCH 5/8] =?UTF-8?q?M3-334=20Feat=20:=20=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=ED=95=9C=20=EA=B7=B8=EB=A3=B9=EC=9D=B4=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=EC=9D=98=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/screens/no_community_screen.dart | 64 ++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 lib/screens/no_community_screen.dart diff --git a/lib/screens/no_community_screen.dart b/lib/screens/no_community_screen.dart new file mode 100644 index 00000000..13605f8c --- /dev/null +++ b/lib/screens/no_community_screen.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../constants/app_colors.dart'; +import '../constants/text_styles.dart'; +import 'search_group_screen.dart'; + +class NoCommunityScreen extends StatelessWidget { + const NoCommunityScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + AppBar( + backgroundColor: AppColors.background, + ), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "가입한 그룹이 없습니다.", + style: TextStyles.fs28w800cTextPrimary, + ), + SizedBox( + height: 5, + ), + Text( + "원하는 그룹을 검색해서 가입해보세요!", + style: TextStyles.fs17w400cTextSecondary, + ), + SizedBox( + height: 40, + ), + InkWell( + borderRadius: BorderRadius.all(Radius.circular(16)), + onTap: () { + Get.to(SearchGroupScreen()); + }, + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + color: AppColors.primary, + ), + height: 60, + width: 200, + child: Expanded( + child: Center( + child: Text( + "그룹 검색", + style: TextStyles.fs17w600cTextBlack, + ), + ), + ), + ), + ), + ], + ), + ), + ], + ); + } +} From d499f397d89305fd02065cf23c1d4d9140cc12af Mon Sep 17 00:00:00 2001 From: Koo Min Date: Thu, 5 Sep 2024 22:52:13 +0900 Subject: [PATCH 6/8] =?UTF-8?q?M3-334=20Feat=20:=20=EA=B7=B8=EB=A3=B9?= =?UTF-8?q?=EC=97=90=20=EA=B0=80=EC=9E=85=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/controllers/navigation_controller.dart | 33 +++++++++++++------ lib/widgets/community/community_image.dart | 38 ++++++++++------------ 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/lib/controllers/navigation_controller.dart b/lib/controllers/navigation_controller.dart index e2aa92a9..9191f948 100644 --- a/lib/controllers/navigation_controller.dart +++ b/lib/controllers/navigation_controller.dart @@ -5,24 +5,18 @@ import 'package:get/get.dart'; import '../screens/community_screen.dart'; import '../screens/map_screen.dart'; import '../screens/my_page_screen.dart'; +import '../screens/no_community_screen.dart'; import '../screens/ranking_screen.dart'; import '../widgets/common/app_bar.dart'; import 'map_controller.dart'; +import 'my_page_controller.dart'; import 'ranking_controller.dart'; class NavigationController extends GetxController { final RankingController rankingController = Get.find(); final MapController mapController = Get.find(); final RxInt selectedIndex = 0.obs; - static List tabPages = [ - const MapScreen(), - const RankingScreen(), - const CommunityScreen( - groupId: 1, - isTap: true, - ), - const MyPageScreen(), - ]; + static List appBars = [ const MapAppBar(), const RankingAppBar(), @@ -54,7 +48,26 @@ class NavigationController extends GetxController { } Widget getCurrentPage() { - return tabPages[selectedIndex.value]; + MyPageController myPageController = Get.find(); + switch (selectedIndex.value) { + case 0: + return MapScreen(); + case 1: + return RankingScreen(); + case 2: + if (myPageController.currentUserInfo.value.communityId == null) { + return const NoCommunityScreen(); + } else { + return CommunityScreen( + groupId: myPageController.currentUserInfo.value.communityId!, + isTap: true, + ); + } + case 3: + return MyPageScreen(); + default: + return Container(); + } } Widget getCurrentAppBar() { diff --git a/lib/widgets/community/community_image.dart b/lib/widgets/community/community_image.dart index 5aa69434..e34fe335 100644 --- a/lib/widgets/community/community_image.dart +++ b/lib/widgets/community/community_image.dart @@ -10,32 +10,28 @@ class CommunityImage extends StatelessWidget { Widget build(BuildContext context) { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { -// Image width is 80% of the available width - double aspectRatio = 350 / 350; // Original aspect ratio - return AspectRatio( - aspectRatio: aspectRatio, - child: Stack( - children: [ - Image( + return Stack( + children: [ + Positioned.fill( + child: Image( image: CachedNetworkImageProvider(imageUrl), - width: constraints.maxWidth, fit: BoxFit.cover, ), - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0x1A000000), // 위쪽은 투명색 - Colors.black, // 아래쪽은 검은색 - ], - stops: [0.8, 1.0], - ), + ), + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0x1A000000), + Colors.black, + ], + stops: [0.8, 1.0], ), ), - ], - ), + ), + ], ); }, ); From cec5f1b0c1b35b5d311d177b314da9d99fe1c91f Mon Sep 17 00:00:00 2001 From: Koo Min Date: Fri, 6 Sep 2024 16:59:04 +0900 Subject: [PATCH 7/8] =?UTF-8?q?M3-334=20Feat=20:=20=ED=83=AD=EB=B0=94?= =?UTF-8?q?=EC=99=80=20=EA=B2=80=EC=83=89=EA=B2=B0=EA=B3=BC=20=EC=B0=BD=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/controllers/community_controller.dart | 26 ++- .../community_info_controller.dart | 52 +++++ lib/controllers/navigation_controller.dart | 30 +-- lib/screens/community_info_screen.dart | 138 ++++++++++++ lib/screens/community_screen.dart | 197 +++++++++--------- lib/screens/no_community_screen.dart | 14 +- .../community/community_action_button.dart | 95 +++++---- 7 files changed, 374 insertions(+), 178 deletions(-) create mode 100644 lib/controllers/community_info_controller.dart create mode 100644 lib/screens/community_info_screen.dart diff --git a/lib/controllers/community_controller.dart b/lib/controllers/community_controller.dart index 7fee99c3..cc582033 100644 --- a/lib/controllers/community_controller.dart +++ b/lib/controllers/community_controller.dart @@ -3,11 +3,13 @@ import 'package:get/get.dart'; import '../models/community.dart'; import '../models/ranking.dart'; import '../service/community_service.dart'; +import 'my_page_controller.dart'; class CommunityController extends GetxController { final CommunityService communityService = CommunityService(); final RxString name = "".obs; final RxString imageUrl = "".obs; + final RxInt communityId = 0.obs; final RxInt memberCount = 0.obs; final RxInt communityColor = 0.obs; final RxInt communityRanking = 0.obs; @@ -26,8 +28,21 @@ class CommunityController extends GetxController { Ranking(userId: 1, rank: 5, currentPixelCount: 123, nickname: "test5"), ].obs; - init(int communityId) async { - Community community = await communityService.getCommunityInfo(communityId); + init() async { + MyPageController myPageController = Get.find(); + if (myPageController.currentUserInfo.value.communityId == null) { + isJoin.value = false; + } else { + await updateCommunityInfo(); + } + } + + updateCommunityInfo() async { + isJoin.value = true; + communityId.value = + Get.find().currentUserInfo.value.communityId!; + Community community = + await communityService.getCommunityInfo(communityId.value); name.value = community.name; imageUrl.value = community.backgroundImageUrl; memberCount.value = community.memberCount; @@ -39,4 +54,11 @@ class CommunityController extends GetxController { maxRanking.value = community.maxRanking; isLoading.value = false; } + + quitCommunity() { + // ToDo : 그룹 탈퇴 구현 + MyPageController myPageController = Get.find(); + myPageController.updateUserInfo(); + isJoin.value = false; + } } diff --git a/lib/controllers/community_info_controller.dart b/lib/controllers/community_info_controller.dart new file mode 100644 index 00000000..8cb402e6 --- /dev/null +++ b/lib/controllers/community_info_controller.dart @@ -0,0 +1,52 @@ +import 'package:get/get.dart'; + +import '../models/community.dart'; +import '../models/ranking.dart'; +import '../service/community_service.dart'; +import 'community_controller.dart'; +import 'my_page_controller.dart'; + +class CommunityInfoController extends GetxController { + final CommunityService communityService = CommunityService(); + final RxString name = "".obs; + final RxString imageUrl = "".obs; + final RxInt memberCount = 0.obs; + final RxInt communityColor = 0.obs; + final RxInt communityRanking = 0.obs; + final RxInt currentPixelCount = 0.obs; + final RxInt accumulatePixelCount = 0.obs; + final RxInt maxPixelCount = 0.obs; + final RxInt maxRanking = 0.obs; + final RxBool isJoin = true.obs; + final RxBool isLoading = true.obs; + + final RxList members = [ + Ranking(userId: 1, rank: 1, currentPixelCount: 123, nickname: "test1"), + Ranking(userId: 1, rank: 2, currentPixelCount: 123, nickname: "test2"), + Ranking(userId: 1, rank: 3, currentPixelCount: 123, nickname: "test3"), + Ranking(userId: 1, rank: 4, currentPixelCount: 123, nickname: "test4"), + Ranking(userId: 1, rank: 5, currentPixelCount: 123, nickname: "test5"), + ].obs; + + init(int communityId) async { + Community community = await communityService.getCommunityInfo(communityId); + name.value = community.name; + imageUrl.value = community.backgroundImageUrl; + memberCount.value = community.memberCount; + communityColor.value = community.communityColor; + communityRanking.value = community.communityRanking; + currentPixelCount.value = community.currentPixelCount; + accumulatePixelCount.value = community.accumulatePixelCount; + maxPixelCount.value = community.maxPixelCount; + maxRanking.value = community.maxRanking; + isLoading.value = false; + } + + signUpCommunity() async { + // ToDo : 그룹 가입 구현 + MyPageController myPageController = Get.find(); + CommunityController communityController = Get.find(); + await myPageController.updateUserInfo(); + communityController.updateCommunityInfo(); + } +} diff --git a/lib/controllers/navigation_controller.dart b/lib/controllers/navigation_controller.dart index 9191f948..ecf70c72 100644 --- a/lib/controllers/navigation_controller.dart +++ b/lib/controllers/navigation_controller.dart @@ -5,11 +5,9 @@ import 'package:get/get.dart'; import '../screens/community_screen.dart'; import '../screens/map_screen.dart'; import '../screens/my_page_screen.dart'; -import '../screens/no_community_screen.dart'; import '../screens/ranking_screen.dart'; import '../widgets/common/app_bar.dart'; import 'map_controller.dart'; -import 'my_page_controller.dart'; import 'ranking_controller.dart'; class NavigationController extends GetxController { @@ -17,6 +15,13 @@ class NavigationController extends GetxController { final MapController mapController = Get.find(); final RxInt selectedIndex = 0.obs; + static List tabPages = [ + const MapScreen(), + const RankingScreen(), + const CommunityScreen(), + const MyPageScreen(), + ]; + static List appBars = [ const MapAppBar(), const RankingAppBar(), @@ -48,26 +53,7 @@ class NavigationController extends GetxController { } Widget getCurrentPage() { - MyPageController myPageController = Get.find(); - switch (selectedIndex.value) { - case 0: - return MapScreen(); - case 1: - return RankingScreen(); - case 2: - if (myPageController.currentUserInfo.value.communityId == null) { - return const NoCommunityScreen(); - } else { - return CommunityScreen( - groupId: myPageController.currentUserInfo.value.communityId!, - isTap: true, - ); - } - case 3: - return MyPageScreen(); - default: - return Container(); - } + return tabPages[selectedIndex.value]; } Widget getCurrentAppBar() { diff --git a/lib/screens/community_info_screen.dart b/lib/screens/community_info_screen.dart new file mode 100644 index 00000000..a9a90248 --- /dev/null +++ b/lib/screens/community_info_screen.dart @@ -0,0 +1,138 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:get/get.dart'; + +import '../constants/app_colors.dart'; +import '../controllers/community_info_controller.dart'; +import '../widgets/community/community_action_button.dart'; +import '../widgets/community/community_image.dart'; +import '../widgets/community/community_info.dart'; +import '../widgets/community/community_record.dart'; +import '../widgets/community/member/member_list.dart'; + +class CommunityInfoScreen extends StatelessWidget { + final int groupId; + + const CommunityInfoScreen({ + super.key, + required this.groupId, + }); + + @override + Widget build(BuildContext context) { + final CommunityInfoController communityInfoController = + Get.put(CommunityInfoController()); + communityInfoController.init(groupId); + + return Scaffold( + backgroundColor: Colors.black, + body: Obx(() { + if (communityInfoController.isLoading.value) { + return const Center( + child: CircularProgressIndicator( + color: AppColors.primary, + ), + ); + } else { + return CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 350.0, + floating: false, + pinned: true, + iconTheme: IconThemeData( + color: Colors.white, + ), + leading: IconButton( + icon: Icon(Icons.arrow_back_ios), + onPressed: () { + Get.back(); + }, + ), + actions: [ + IconButton( + icon: SvgPicture.asset( + 'assets/images/share_icon.svg', + width: 20, + ), + onPressed: () {}, + ), + ], + backgroundColor: AppColors.background, + flexibleSpace: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + var top = constraints.biggest.height; + return FlexibleSpaceBar( + title: top <= 120 + ? Text( + communityInfoController.name.value, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ) + : Align( + alignment: Alignment.bottomLeft, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10.0), + child: Text( + communityInfoController.name.value, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 20, + ), + ), + ), + ), + background: CommunityImage( + imageUrl: communityInfoController.imageUrl.value, + ), + collapseMode: CollapseMode.parallax, + ); + }, + ), + ), + SliverToBoxAdapter( + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + children: [ + CommunityInfo( + memberCount: communityInfoController.memberCount, + communityColor: communityInfoController.communityColor, + weeklyRanking: communityInfoController.communityRanking, + ), + SizedBox( + height: 20, + ), + CommunityRecord( + currentPixelCount: + communityInfoController.currentPixelCount, + accumulatePixelCount: + communityInfoController.accumulatePixelCount, + maxPixelCount: communityInfoController.maxPixelCount, + maxRankingCount: communityInfoController.maxRanking, + ), + SizedBox( + height: 20, + ), + MemberList(members: communityInfoController.members), + SizedBox( + height: 20, + ), + SignUpCommunityButton( + onTap: communityInfoController.signUpCommunity, + ), + ], + ), + ), + ), + ], + ); + } + }), + ); + } +} diff --git a/lib/screens/community_screen.dart b/lib/screens/community_screen.dart index 6754fb0d..9e20daa7 100644 --- a/lib/screens/community_screen.dart +++ b/lib/screens/community_screen.dart @@ -9,129 +9,122 @@ import '../widgets/community/community_image.dart'; import '../widgets/community/community_info.dart'; import '../widgets/community/community_record.dart'; import '../widgets/community/member/member_list.dart'; +import 'no_community_screen.dart'; class CommunityScreen extends StatelessWidget { - final int groupId; - final bool isTap; - const CommunityScreen({ super.key, - required this.groupId, - required this.isTap, }); @override Widget build(BuildContext context) { final CommunityController communityController = Get.put(CommunityController()); - communityController.init(groupId); + communityController.init(); return Obx(() { - if (communityController.isLoading.value) { - return const Center( - child: CircularProgressIndicator( - color: AppColors.primary, - ), - ); + if (!communityController.isJoin.value) { + return NoCommunityScreen(); } else { - return CustomScrollView( - slivers: [ - SliverAppBar( - expandedHeight: 350.0, - floating: false, - pinned: true, - iconTheme: IconThemeData( - color: Colors.white, - ), - leading: isTap - ? null - : IconButton( - icon: Icon(Icons.arrow_back_ios), - onPressed: () { - Get.back(); - }, + if (communityController.isLoading.value) { + return const Center( + child: CircularProgressIndicator( + color: AppColors.primary, + ), + ); + } else { + return CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: 350.0, + floating: false, + pinned: true, + iconTheme: IconThemeData( + color: Colors.white, + ), + actions: [ + IconButton( + icon: SvgPicture.asset( + 'assets/images/share_icon.svg', + width: 20, ), - actions: [ - IconButton( - icon: SvgPicture.asset( - 'assets/images/share_icon.svg', - width: 20, + onPressed: () {}, ), - onPressed: () {}, - ), - ], - backgroundColor: AppColors.background, - flexibleSpace: LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - var top = constraints.biggest.height; - return FlexibleSpaceBar( - title: top <= 120 - ? Text( - communityController.name.value, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - ), - ) - : Align( - alignment: Alignment.bottomLeft, - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 10.0), - child: Text( - communityController.name.value, - style: TextStyle( - color: Colors.white, - fontWeight: FontWeight.bold, - fontSize: 20, + ], + backgroundColor: AppColors.background, + flexibleSpace: LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + var top = constraints.biggest.height; + return FlexibleSpaceBar( + title: top <= 120 + ? Text( + communityController.name.value, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ) + : Align( + alignment: Alignment.bottomLeft, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10.0), + child: Text( + communityController.name.value, + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 20, + ), ), ), ), - ), - background: CommunityImage( - imageUrl: communityController.imageUrl.value, - ), - collapseMode: CollapseMode.parallax, - ); - }, + background: CommunityImage( + imageUrl: communityController.imageUrl.value, + ), + collapseMode: CollapseMode.parallax, + ); + }, + ), ), - ), - SliverToBoxAdapter( - child: Padding( - padding: EdgeInsets.all(10), - child: Column( - children: [ - CommunityInfo( - memberCount: communityController.memberCount, - communityColor: communityController.communityColor, - weeklyRanking: communityController.communityRanking, - ), - SizedBox( - height: 20, - ), - CommunityRecord( - currentPixelCount: communityController.currentPixelCount, - accumulatePixelCount: - communityController.accumulatePixelCount, - maxPixelCount: communityController.maxPixelCount, - maxRankingCount: communityController.maxRanking, - ), - SizedBox( - height: 20, - ), - MemberList(members: communityController.members), - SizedBox( - height: 20, - ), - CommunityActionButton( - isJoin: communityController.isJoin.value, - ), - ], + SliverToBoxAdapter( + child: Padding( + padding: EdgeInsets.all(10), + child: Column( + children: [ + CommunityInfo( + memberCount: communityController.memberCount, + communityColor: communityController.communityColor, + weeklyRanking: communityController.communityRanking, + ), + SizedBox( + height: 20, + ), + CommunityRecord( + currentPixelCount: + communityController.currentPixelCount, + accumulatePixelCount: + communityController.accumulatePixelCount, + maxPixelCount: communityController.maxPixelCount, + maxRankingCount: communityController.maxRanking, + ), + SizedBox( + height: 20, + ), + MemberList(members: communityController.members), + SizedBox( + height: 20, + ), + QuitCommunityButton( + onTap: communityController.quitCommunity, + ), + ], + ), ), ), - ), - ], - ); + ], + ); + } } }); } diff --git a/lib/screens/no_community_screen.dart b/lib/screens/no_community_screen.dart index 13605f8c..c0767fb4 100644 --- a/lib/screens/no_community_screen.dart +++ b/lib/screens/no_community_screen.dart @@ -3,7 +3,7 @@ import 'package:get/get.dart'; import '../constants/app_colors.dart'; import '../constants/text_styles.dart'; -import 'search_group_screen.dart'; +import 'community_info_screen.dart'; class NoCommunityScreen extends StatelessWidget { const NoCommunityScreen({super.key}); @@ -36,7 +36,7 @@ class NoCommunityScreen extends StatelessWidget { InkWell( borderRadius: BorderRadius.all(Radius.circular(16)), onTap: () { - Get.to(SearchGroupScreen()); + Get.to(CommunityInfoScreen(groupId: 20)); }, child: Ink( decoration: BoxDecoration( @@ -45,12 +45,10 @@ class NoCommunityScreen extends StatelessWidget { ), height: 60, width: 200, - child: Expanded( - child: Center( - child: Text( - "그룹 검색", - style: TextStyles.fs17w600cTextBlack, - ), + child: Center( + child: Text( + "그룹 검색", + style: TextStyles.fs17w600cTextBlack, ), ), ), diff --git a/lib/widgets/community/community_action_button.dart b/lib/widgets/community/community_action_button.dart index 6a3d8245..db7262ea 100644 --- a/lib/widgets/community/community_action_button.dart +++ b/lib/widgets/community/community_action_button.dart @@ -3,57 +3,64 @@ import 'package:flutter/material.dart'; import '../../constants/app_colors.dart'; import '../../constants/text_styles.dart'; -class CommunityActionButton extends StatelessWidget { - final bool isJoin; +class QuitCommunityButton extends StatelessWidget { + final Function onTap; - const CommunityActionButton({super.key, required this.isJoin}); + const QuitCommunityButton({super.key, required this.onTap}); @override Widget build(BuildContext context) { - if (isJoin) { - return InkWell( - borderRadius: BorderRadius.all(Radius.circular(16)), - onTap: () { - //Todo : 그룹 탈퇴 로직 - }, - child: Ink( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - color: AppColors.boxColor, - ), - height: 60, - width: 1000, - child: Center( - child: Text( - "그룹 탈퇴", - style: TextStyles.fs17w600cAccent, - ), - ), + return InkWell( + borderRadius: BorderRadius.all(Radius.circular(16)), + onTap: () { + onTap(); + //Todo : 그룹 탈퇴 로직 + }, + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + color: AppColors.boxColor, ), - ); - } else { - return InkWell( - borderRadius: BorderRadius.all(Radius.circular(16)), - onTap: () { - //Todo : 그룹 가입 로직 - }, - child: Ink( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - color: AppColors.primary, + height: 60, + width: 1000, + child: Center( + child: Text( + "그룹 탈퇴", + style: TextStyles.fs17w600cAccent, ), - height: 60, - width: 1000, - child: Expanded( - child: Center( - child: Text( - "그룹 가입 신청하기", - style: TextStyles.fs17w600cTextBlack, - ), - ), + ), + ), + ); + } +} + +class SignUpCommunityButton extends StatelessWidget { + final Function onTap; + + const SignUpCommunityButton({super.key, required this.onTap}); + + @override + Widget build(BuildContext context) { + return InkWell( + borderRadius: BorderRadius.all(Radius.circular(16)), + onTap: () { + onTap(); + //Todo : 그룹 가입 로직 + }, + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + color: AppColors.primary, + ), + height: 60, + width: 1000, + child: Center( + child: Text( + "그룹 가입 신청하기", + style: TextStyles.fs17w600cTextBlack, ), ), - ); - } + ), + ); } } From f36eba3430631652aac2852aed8cfbab764a85d5 Mon Sep 17 00:00:00 2001 From: Koo Min Date: Fri, 6 Sep 2024 17:28:32 +0900 Subject: [PATCH 8/8] M3-334 Refactor : dart fix --- lib/controllers/community_info_controller.dart | 1 - lib/screens/community_info_screen.dart | 3 ++- lib/screens/community_screen.dart | 3 ++- lib/screens/no_community_screen.dart | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/controllers/community_info_controller.dart b/lib/controllers/community_info_controller.dart index 8cb402e6..48e6cb1d 100644 --- a/lib/controllers/community_info_controller.dart +++ b/lib/controllers/community_info_controller.dart @@ -17,7 +17,6 @@ class CommunityInfoController extends GetxController { final RxInt accumulatePixelCount = 0.obs; final RxInt maxPixelCount = 0.obs; final RxInt maxRanking = 0.obs; - final RxBool isJoin = true.obs; final RxBool isLoading = true.obs; final RxList members = [ diff --git a/lib/screens/community_info_screen.dart b/lib/screens/community_info_screen.dart index a9a90248..7b800e55 100644 --- a/lib/screens/community_info_screen.dart +++ b/lib/screens/community_info_screen.dart @@ -75,7 +75,8 @@ class CommunityInfoScreen extends StatelessWidget { alignment: Alignment.bottomLeft, child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 10.0), + horizontal: 10.0, + ), child: Text( communityInfoController.name.value, style: TextStyle( diff --git a/lib/screens/community_screen.dart b/lib/screens/community_screen.dart index 9e20daa7..244ac557 100644 --- a/lib/screens/community_screen.dart +++ b/lib/screens/community_screen.dart @@ -68,7 +68,8 @@ class CommunityScreen extends StatelessWidget { alignment: Alignment.bottomLeft, child: Padding( padding: const EdgeInsets.symmetric( - horizontal: 10.0), + horizontal: 10.0, + ), child: Text( communityController.name.value, style: TextStyle( diff --git a/lib/screens/no_community_screen.dart b/lib/screens/no_community_screen.dart index c0767fb4..f28282cf 100644 --- a/lib/screens/no_community_screen.dart +++ b/lib/screens/no_community_screen.dart @@ -3,7 +3,7 @@ import 'package:get/get.dart'; import '../constants/app_colors.dart'; import '../constants/text_styles.dart'; -import 'community_info_screen.dart'; +import 'search_group_screen.dart'; class NoCommunityScreen extends StatelessWidget { const NoCommunityScreen({super.key}); @@ -36,7 +36,7 @@ class NoCommunityScreen extends StatelessWidget { InkWell( borderRadius: BorderRadius.all(Radius.circular(16)), onTap: () { - Get.to(CommunityInfoScreen(groupId: 20)); + Get.to(SearchGroupScreen()); }, child: Ink( decoration: BoxDecoration(