Skip to content

Commit

Permalink
1.11.0 - Few small fixes (#202)
Browse files Browse the repository at this point in the history
* actively updating the playthrough time

* fixing issue with setting score to 0 points

* fixing app iOS deployment pipeline
  • Loading branch information
mkieres authored Jun 18, 2023
1 parent 2dd3ce4 commit 4073ab2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
2 changes: 2 additions & 0 deletions board_games_companion/lib/models/hive/score.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ class Score with _$Score {
const Score._();

int get valueInt => int.tryParse(value ?? '0') ?? 0;

bool get hasScore => value != null || noScoreGameResult?.cooperativeGameResult != null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '../../models/hive/player.dart';
import '../../models/hive/playthrough_note.dart';
import '../../models/navigation/playthough_note_page_arguments.dart';
import '../../models/player_score.dart';
import '../../utilities/periodic_boardcast_stream.dart';
import '../../widgets/common/page_container.dart';
import '../../widgets/common/slivers/bgc_sliver_title_header_delegate.dart';
import '../../widgets/player/player_avatar.dart';
Expand Down Expand Up @@ -568,18 +569,33 @@ class _PlayDateTimeSectionState extends State<_PlayDateTimeSection> {
late int minMinutes;
late int maxMinutes;

// MK An arbitrary number of seconds to refresh the duration
final PeriodicBroadcastStream _refreshPlayDurationPeriodicStream =
PeriodicBroadcastStream(const Duration(seconds: 10));

@override
void initState() {
super.initState();

if (!widget.viewModel.playthoughEnded) {
_refreshPlayDurationPeriodicStream.stream.listen(_updateDuration);
}
}

@override
void dispose() {
_refreshPlayDurationPeriodicStream.dispose();

super.dispose();
}

@override
Widget build(BuildContext context) {
playthroughDuration = widget.viewModel.playthoughDuration;
playthroughDurationInSeconds = playthroughDuration.inSeconds;
hoursPlayed = playthroughDuration.inHours;
minutesPlyed = playthroughDuration.inMinutes - hoursPlayed * Duration.minutesPerHour;
}

@override
Widget build(BuildContext context) {
_setHourseAndMinutesRange();
return MultiSliver(
children: [
Expand Down Expand Up @@ -646,14 +662,28 @@ class _PlayDateTimeSectionState extends State<_PlayDateTimeSection> {
);
}

void _updateDuration(void _) {
if (mounted && !widget.viewModel.playthoughEnded) {
setState(() {});
}
}

void _updateDurationHours(num value) {
if (!widget.viewModel.playthoughEnded) {
return;
}

setState(() {
hoursPlayed = value.toInt();
widget.viewModel.updateDuration(hoursPlayed, minutesPlyed);
});
}

void _updateDurationMinutes(num value) {
if (!widget.viewModel.playthoughEnded) {
return;
}

setState(() {
minutesPlyed = value.toInt();
widget.viewModel.updateDuration(hoursPlayed, minutesPlyed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ abstract class _EditPlaythoughViewModel with Store {

@action
void updatePlayerScore(PlayerScore playerScore, int newScore) {
if (playerScore.score.valueInt == newScore) {
if (playerScore.score.hasScore && playerScore.score.valueInt == newScore) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion pipelines/mobile_app/deploy-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ stages:
channel: "stable"
version: "custom"
customVersion: $(flutter.version)
dartDefineMulti: searchBoardGamesApiBaseUrl=$(searchApiBaseUrl) searchBoardGamesApiSubscriptionKey=$(searchApiSubscriptionKey)

- task: InstallAppleCertificate@2
inputs:
Expand All @@ -189,6 +188,7 @@ stages:
projectDirectory: "$(Build.SourcesDirectory)/$(appDirectoryName)"
buildNumber: "$(Build.BuildID)"
buildName: "$(appVersion)"
dartDefineMulti: searchBoardGamesApiBaseUrl=$(searchApiBaseUrl) searchBoardGamesApiSubscriptionKey=$(searchApiSubscriptionKey)

- task: Xcode@5
inputs:
Expand Down

0 comments on commit 4073ab2

Please sign in to comment.