From c98acbdf1ad3871735903711e56e35ea8e98e2c2 Mon Sep 17 00:00:00 2001 From: w8385 Date: Mon, 5 Jun 2023 13:58:29 +0900 Subject: [PATCH] feat: Badge categorize --- my_solved/lib/assets/icons/badge.svg | 18 +++---- my_solved/lib/widgets/user_widget.dart | 68 ++++++++++++++++++++------ 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/my_solved/lib/assets/icons/badge.svg b/my_solved/lib/assets/icons/badge.svg index 8f7ffc93..575c7978 100644 --- a/my_solved/lib/assets/icons/badge.svg +++ b/my_solved/lib/assets/icons/badge.svg @@ -1,13 +1,7 @@ - - - - - - - - - - + + + + \ No newline at end of file diff --git a/my_solved/lib/widgets/user_widget.dart b/my_solved/lib/widgets/user_widget.dart index 6e690a82..9fbe55e4 100644 --- a/my_solved/lib/widgets/user_widget.dart +++ b/my_solved/lib/widgets/user_widget.dart @@ -854,14 +854,14 @@ Widget badges(BuildContext context, Future future) { } temp[0].sort((a, b) => a['badgeId'].compareTo(b['badgeId'])); - List badges = []; + List badges = [[], [], [], []]; for (int i = 0; i < 4; i++) { for (int j = 0; j < temp[i].length; j++) { - badges.add(temp[i][j]); + badges[i].add(temp[i][j]); } } - Widget badgeTier(BuildContext context, dynamic badge, int idx) { + Widget badgeTier(BuildContext context, dynamic badge) { String tier = badge['badgeTier']; bool isContest = badge['badgeCategory'] == 'contest'; Color tierColor = Colors.white; @@ -954,20 +954,60 @@ Widget badges(BuildContext context, Future future) { ); } + const badgeCategory = ['도전과제', '시즌 도전과제', '이벤트', '대회']; + + Widget badgeContainer(BuildContext context, int category) { + return Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + ), + margin: EdgeInsets.only( + left: MediaQuery.of(context).size.width * 0.05), + // padding: const EdgeInsets.all(10), + child: Row( + children: [ + SvgPicture.asset( + 'lib/assets/icons/badge.svg', + width: MediaQuery.of(context).size.width * 0.04, + color: Colors.black45, + ), + const SizedBox(width: 5), + Text( + badgeCategory[category], + style: TextStyle( + fontSize: MediaQuery.of(context).size.width * 0.04, + color: Colors.black45, + ), + ), + ], + ), + ), + GridView.builder( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 6, + childAspectRatio: 1, + ), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: badges[category].length, + itemBuilder: (BuildContext context, int index) { + return badgeTier(context, badges[category][index]); + }), + Divider( + color: Colors.black12, + thickness: 1, + ) + ], + ); + } + return Column( children: [ const SizedBox(height: 10), - GridView.builder( - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 6, - childAspectRatio: 1, - ), - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemCount: count, - itemBuilder: (BuildContext context, int index) { - return badgeTier(context, badges[index], index); - }) + for (int i = 0; i < 4; i++) badgeContainer(context, i), ], ); } else {