diff --git a/lib/components/gamification_xpbar.dart b/lib/components/gamification_xpbar.dart new file mode 100644 index 0000000..7ce2895 --- /dev/null +++ b/lib/components/gamification_xpbar.dart @@ -0,0 +1,29 @@ +import 'package:assosnation_app/utils/constants.dart'; +import 'package:assosnation_app/utils/imports/commons.dart'; + +class GamificationXpBar extends StatelessWidget { + const GamificationXpBar({Key? key, required this.exp, required this.level}) + : super(key: key); + + final int exp; + final int level; + + @override + Widget build(BuildContext context) { + return Stack(children: [ + LinearProgressIndicator( + value: (exp % Constants.xpToLevelMultiplier) / + Constants.xpToLevelMultiplier, + backgroundColor: Colors.teal[100], + valueColor: + AlwaysStoppedAnimation(Theme.of(context).primaryColor), + minHeight: 20, + color: Colors.teal[200], + ), + Align( + alignment: Alignment.center, + child: + Text("$exp exp", style: Theme.of(context).textTheme.subtitle1)), + ]); + } +} diff --git a/lib/pages/detail/association_details.dart b/lib/pages/detail/association_details.dart index 62a253f..f57ac41 100644 --- a/lib/pages/detail/association_details.dart +++ b/lib/pages/detail/association_details.dart @@ -13,6 +13,7 @@ import 'package:assosnation_app/services/models/user.dart'; import 'package:assosnation_app/utils/converters.dart'; import 'package:assosnation_app/utils/imports/commons.dart'; import 'package:assosnation_app/utils/utils.dart'; +import 'package:cached_network_image/cached_network_image.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:provider/provider.dart'; @@ -53,9 +54,12 @@ class AssociationDetails extends StatelessWidget { children: [ Column( children: [ - Image.network( - _association.banner, - width: MediaQuery.of(context).size.width, + AspectRatio( + aspectRatio: 4 / 3, + child: CachedNetworkImage( + imageUrl: _association.banner, + fit: BoxFit.scaleDown, + ), ), ], ), diff --git a/lib/pages/user/profile_page.dart b/lib/pages/user/profile_page.dart index 39b64a9..d3c8fd3 100644 --- a/lib/pages/user/profile_page.dart +++ b/lib/pages/user/profile_page.dart @@ -1,5 +1,6 @@ import 'package:assosnation_app/components/an_title.dart'; import 'package:assosnation_app/components/dialog/are_you_sure_dialog.dart'; +import 'package:assosnation_app/components/gamification_xpbar.dart'; import 'package:assosnation_app/services/firebase/firestore/firestore_service.dart'; import 'package:assosnation_app/services/firebase/firestore/gamification_service.dart'; import 'package:assosnation_app/services/firebase/firestore/user_service.dart'; @@ -151,13 +152,9 @@ class _ProfileState extends State { milliseconds: 500)), ), ]), - LinearProgressIndicator( - value: (gamification.exp % - Constants.xpToLevelMultiplier) / - Constants.xpToLevelMultiplier, - backgroundColor: Colors.grey, - valueColor: AlwaysStoppedAnimation( - Theme.of(context).primaryColor)), + GamificationXpBar( + level: gamification.level, + exp: gamification.exp), ], ), ); diff --git a/lib/utils/constants.dart b/lib/utils/constants.dart index 10dd4b2..56b977f 100644 --- a/lib/utils/constants.dart +++ b/lib/utils/constants.dart @@ -1,6 +1,6 @@ class Constants { static String appName = "AssosNation"; - static int xpToLevelMultiplier = 250; + static int xpToLevelMultiplier = 500; static int likeCountExpValue = 25; static int loginCountExpValue = 35; static int subCountExpValue = 75; @@ -9,4 +9,8 @@ class Constants { static String fullHorizontalLogoPath = "assets/icon/logo_an_full_hori.png"; static String logoPath = "assets/icon/logo_an.png"; static double appBarLogoScale = 3.8; + static int allCoeffs = likeCountExpValue + + loginCountExpValue + + subCountExpValue + + eventRegistrationsExpValue; }