Skip to content

Commit

Permalink
Changed design for XpBar in profile_page.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
lexinor committed Jul 4, 2021
1 parent 0a05374 commit 04d6bab
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
29 changes: 29 additions & 0 deletions lib/components/gamification_xpbar.dart
Original file line number Diff line number Diff line change
@@ -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<Color>(Theme.of(context).primaryColor),
minHeight: 20,
color: Colors.teal[200],
),
Align(
alignment: Alignment.center,
child:
Text("$exp exp", style: Theme.of(context).textTheme.subtitle1)),
]);
}
}
10 changes: 7 additions & 3 deletions lib/pages/detail/association_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
),
),
],
),
Expand Down
11 changes: 4 additions & 7 deletions lib/pages/user/profile_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -151,13 +152,9 @@ class _ProfileState extends State<Profile> {
milliseconds: 500)),
),
]),
LinearProgressIndicator(
value: (gamification.exp %
Constants.xpToLevelMultiplier) /
Constants.xpToLevelMultiplier,
backgroundColor: Colors.grey,
valueColor: AlwaysStoppedAnimation<Color>(
Theme.of(context).primaryColor)),
GamificationXpBar(
level: gamification.level,
exp: gamification.exp),
],
),
);
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/constants.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}

0 comments on commit 04d6bab

Please sign in to comment.