Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitletondor committed Jul 14, 2018
2 parents 4b6805c + 48f86b3 commit c937644
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 69 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ android {
applicationId "com.benoitletondor.beermeup"
minSdkVersion 21
targetSdkVersion 27
versionCode 10
versionName "1.1.0"
versionCode 11
versionName "1.1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand Down
4 changes: 2 additions & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<string>1.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -31,7 +31,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>10</string>
<string>11</string>
<key>FacebookAppID</key>
<string>204596980298393</string>
<key>FacebookDisplayName</key>
Expand Down
57 changes: 57 additions & 0 deletions lib/common/widget/ratingstars.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:meta/meta.dart';
import 'package:flutter_stream_friends/flutter_stream_friends.dart';
import 'package:beer_me_up/common/hapticfeedback.dart';

class RatingStars extends StatelessWidget {
final int rating;
final double size;
final ValueStreamCallback<int> onTap;
final double paddingBetweenStars;
final MainAxisAlignment alignment;

RatingStars({
@required this.rating,
@required this.size,
this.onTap,
this.paddingBetweenStars,
this.alignment,
});

@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: alignment ?? MainAxisAlignment.start,
children: <Widget>[
_buildStar(1, rating >= 1, context),
_buildStar(2, rating >= 2, context),
_buildStar(3, rating >= 3, context),
_buildStar(4, rating >= 4, context),
_buildStar(5, rating >= 5, context),
],
);
}

Widget _buildStar(int index, bool selected, BuildContext context) {
return Material(
type: MaterialType.transparency,
child: InkWell(
enableFeedback: onTap != null,
onTap: onTap != null ? () {
performSelectionHaptic(context);
onTap(index);
} : null,
borderRadius: const BorderRadius.all(Radius.circular(50.0)),
child: Container(
padding: EdgeInsets.all(paddingBetweenStars ?? 0.0),
child: Icon(
selected ? Icons.star : Icons.star_border,
color: Colors.amberAccent[400],
size: size,
),
),
),
);
}

}
51 changes: 15 additions & 36 deletions lib/page/checkindisplay/checkindisplaypage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import 'package:beer_me_up/service/userdataservice.dart';
import 'package:beer_me_up/common/mvi/viewstate.dart';
import 'package:beer_me_up/common/widget/loadingwidget.dart';
import 'package:beer_me_up/common/widget/erroroccurredwidget.dart';
import 'package:beer_me_up/common/hapticfeedback.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:beer_me_up/localization/localization.dart';
import 'package:beer_me_up/model/checkin.dart';
import 'package:beer_me_up/model/beer.dart';
import 'package:beer_me_up/common/widget/ratingstars.dart';

import 'model.dart';
import 'intent.dart';
Expand Down Expand Up @@ -90,7 +90,13 @@ class _CheckInDisplayPageState extends ViewState<CheckInDisplayPage, CheckInDisp
),
),
const Padding(padding: EdgeInsets.only(top: 10.0)),
_buildRatingStars(0),
RatingStars(
rating: 0,
size: 24.0,
onTap: intent.rate,
paddingBetweenStars: 8.0,
alignment: MainAxisAlignment.center,
),
],
);
} else {
Expand All @@ -113,7 +119,13 @@ class _CheckInDisplayPageState extends ViewState<CheckInDisplayPage, CheckInDisp
),
),
const Padding(padding: EdgeInsets.only(top: 10.0)),
_buildRatingStars(rating),
RatingStars(
rating: rating,
size: 24.0,
onTap: intent.rate,
paddingBetweenStars: 8.0,
alignment: MainAxisAlignment.center,
),
],
);
}
Expand Down Expand Up @@ -298,37 +310,4 @@ class _CheckInDisplayPageState extends ViewState<CheckInDisplayPage, CheckInDisp
child: ratingWidget,
);
}

Widget _buildRatingStars(int rating) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildStar(1, rating >= 1),
_buildStar(2, rating >= 2),
_buildStar(3, rating >= 3),
_buildStar(4, rating >= 4),
_buildStar(5, rating >= 5),
],
);
}

Widget _buildStar(int index, bool selected) {
return Material(
type: MaterialType.transparency,
child: InkWell(
onTap: () {
performSelectionHaptic(context);
intent.rate(index);
},
borderRadius: const BorderRadius.all(Radius.circular(50.0)),
child: Container(
padding: const EdgeInsets.all(8.0),
child: Icon(
selected ? Icons.star : Icons.star_border,
color: Colors.amberAccent[400],
),
),
),
);
}
}
4 changes: 1 addition & 3 deletions lib/page/home/profile/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ class ProfileData {
BeerStyle mostDrankCategory;
double mostDrankCategoryCounter = 0.0;

int numberOfRatings = 0;
final Map<int, List<Beer>> beersRating = Map();

for(BeerCheckInsData checkinData in checkInsData) {
Expand All @@ -224,14 +223,13 @@ class ProfileData {
}
}

if( checkinData.rating != null && numberOfRatings < 10 ) {
if( checkinData.rating != null ) {
List<Beer> beersForRating = beersRating[checkinData.rating];
if( beersForRating == null ){
beersForRating = List();
beersRating[checkinData.rating] = beersForRating;
}

numberOfRatings++;
beersForRating.add(checkinData.beer);
}
}
Expand Down
38 changes: 16 additions & 22 deletions lib/page/home/profile/profilepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:beer_me_up/common/mvi/viewstate.dart';
import 'package:beer_me_up/common/widget/beertile.dart';
import 'package:beer_me_up/localization/localization.dart';
import 'package:beer_me_up/common/widget/materialflatbutton.dart';
import 'package:beer_me_up/common/widget/ratingstars.dart';

import 'model.dart';
import 'intent.dart';
Expand Down Expand Up @@ -470,18 +471,32 @@ class _ProfilePageState extends ViewState<ProfilePage, ProfileViewModel, Profile
}

final List<Widget> beers = List();
int numberOfBeers = 0;
for(int i = 5; i>0; i--) {
final List<Beer> starBeers = beersRating[i];
if( starBeers == null ) {
continue;
}

if( numberOfBeers >= 10 ) {
break;
}

starBeers.forEach((beer) {
if( numberOfBeers >= 10 ) {
return;
}

beers.add(BeerTile(
beer: beer,
title: beer.name,
thirdWidget: _buildStars(i),
thirdWidget: RatingStars(
rating: i,
size: 14.0,
),
));

numberOfBeers++;
});
}

Expand All @@ -490,27 +505,6 @@ class _ProfilePageState extends ViewState<ProfilePage, ProfileViewModel, Profile
);
}

Widget _buildStars(int rating) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
_buildStar(1, rating >= 1),
_buildStar(2, rating >= 2),
_buildStar(3, rating >= 3),
_buildStar(4, rating >= 4),
_buildStar(5, rating >= 5),
],
);
}

Widget _buildStar(int index, bool selected) {
return Icon(
selected ? Icons.star : Icons.star_border,
color: Colors.amberAccent[400],
size: 14.0,
);
}

Widget _buildRateCheckInWidget(CheckIn checkInToRate) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 10.0),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ packages:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.11"
version: "0.5.12"
firebase_core:
dependency: transitive
description:
Expand Down Expand Up @@ -239,7 +239,7 @@ packages:
name: intl_translation
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.7"
version: "0.16.8"
io:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ dependencies:
flutter_stream_friends: 0.8.0

intl: 0.15.6
intl_translation: 0.16.7
intl_translation: 0.16.8

google_sign_in: 3.0.4
flutter_facebook_login: 1.1.1
firebase_auth: 0.5.11
firebase_auth: 0.5.12
cloud_firestore: 0.7.3
firebase_analytics: 1.0.1
firebase_remote_config: 0.0.2
Expand Down

0 comments on commit c937644

Please sign in to comment.