Skip to content

Commit

Permalink
1.5.1 - Updating mockups and using enter score dialog on the log game…
Browse files Browse the repository at this point in the history
…s page (#79)

* Update Pixel mockups

* Updating HTC Nexus 9 mockups

* updating iPhone mockups

* Updating mockups for iphone 8 & ipad

* Removing unused code for updating scores and updating logging games entering score
  • Loading branch information
mkieres authored Feb 13, 2022
1 parent 3388321 commit 39e32c2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 108 deletions.
Binary file not shown.
2 changes: 2 additions & 0 deletions board_games_companion/lib/common/app_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ class AppText {
static const enterScoreDialogDoneButtonText = 'Done';

static const filterGamesPanelClearFiltersButtonText = 'Clear filters';

static const playthroughsLogGamePagePlayerScoresStepTitle = 'Player scores';
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@ class _ScoresSectionState extends State<_ScoresSection> {
child: _PlayerScoreTile(
playerScore: viewModel.playerScores[index],
playthroughId: viewModel.playthrough.id,
onUpdatePlayerScore: (num score) async {
_updatePlayerScore(viewModel.playerScores[index], score);
},
),
);
},
Expand All @@ -250,34 +247,17 @@ class _ScoresSectionState extends State<_ScoresSection> {
},
);
}

void _updatePlayerScore(PlayerScore playerScore, num newScore) {
if (newScore < 0) {
return;
}

final String scoreText = newScore.toString();
if (playerScore.score.value == scoreText) {
return;
}

playerScore.updatePlayerScore(scoreText);

setState(() {});
}
}

class _PlayerScoreTile extends StatelessWidget {
const _PlayerScoreTile({
Key? key,
required this.playerScore,
required this.playthroughId,
required this.onUpdatePlayerScore,
}) : super(key: key);

final PlayerScore playerScore;
final String playthroughId;
final Future<void> Function(num) onUpdatePlayerScore;

@override
Widget build(BuildContext context) {
Expand All @@ -295,50 +275,21 @@ class _PlayerScoreTile extends StatelessWidget {
),
const SizedBox(width: Dimensions.standardSpacing),
Expanded(
child: _PlayerScore(
playerScore: playerScore,
onUpdatePlayerScore: onUpdatePlayerScore,
),
child: _PlayerScore(playerScore: playerScore),
),
],
),
);
}
}

class _PlayerScore extends StatefulWidget {
class _PlayerScore extends StatelessWidget {
const _PlayerScore({
Key? key,
required this.playerScore,
required this.onUpdatePlayerScore,
}) : super(key: key);

final PlayerScore playerScore;
final Future<void> Function(num) onUpdatePlayerScore;

@override
State<_PlayerScore> createState() => _PlayerScoreState();
}

class _PlayerScoreState extends State<_PlayerScore> {
late TextEditingController playerScoreEditingController;
late FocusNode playerScoreFocusNode;

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

playerScoreEditingController = TextEditingController(text: widget.playerScore.score.value);
playerScoreFocusNode = FocusNode();
}

@override
void dispose() {
playerScoreEditingController.dispose();
playerScoreFocusNode.dispose();

super.dispose();
}

@override
Widget build(BuildContext context) {
Expand All @@ -350,13 +301,15 @@ class _PlayerScoreState extends State<_PlayerScore> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ChangeNotifierProvider<PlayerScore>.value(
value: widget.playerScore,
child: Consumer<PlayerScore>(builder: (_, playerScore, __) {
return Text(
'${playerScore.score.valueInt}',
style: Styles.playerScoreTextStyle,
);
}),
value: playerScore,
child: Consumer<PlayerScore>(
builder: (_, playerScore, __) {
return Text(
'${playerScore.score.valueInt}',
style: Styles.playerScoreTextStyle,
);
},
),
),
const SizedBox(height: Dimensions.halfStandardSpacing),
Text(AppText.editPlaythroughScorePoints, style: AppTheme.theme.textTheme.bodyText2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import 'package:flutter/material.dart';
import 'package:numberpicker/numberpicker.dart';
import 'package:provider/provider.dart';

import '../../common/app_text.dart';
import '../../common/app_theme.dart';
import '../../common/constants.dart';
import '../../common/dimensions.dart';
import '../../common/styles.dart';
import '../../extensions/date_time_extensions.dart';
import '../../mixins/enter_score_dialog.dart';
import '../../models/hive/board_game_details.dart';
import '../../models/navigation/player_page_arguments.dart';
import '../../models/player_score.dart';
Expand All @@ -18,6 +21,7 @@ import '../../widgets/common/elevated_icon_button.dart';
import '../../widgets/common/text/item_property_value_widget.dart';
import '../../widgets/player/player_avatar.dart';
import '../../widgets/playthrough/calendar_card.dart';
import '../enter_score/enter_score_view_model.dart';
import '../players/player_page.dart';
import '../players/players_view_model.dart';
import 'playthroughs_log_game_view_model.dart';
Expand Down Expand Up @@ -141,7 +145,7 @@ class _LogPlaythroughStepperState extends State<_LogPlaythroughStepper> {
),
),
Step(
title: const Text('Player scores'),
title: const Text(AppText.playthroughsLogGamePagePlayerScoresStepTitle),
isActive: widget.viewModel.playthroughStartTime == PlaythroughStartTime.inThePast,
state: widget.viewModel.playthroughStartTime == PlaythroughStartTime.now
? StepState.disabled
Expand Down Expand Up @@ -293,7 +297,7 @@ class _LogPlaythroughStepperState extends State<_LogPlaythroughStepper> {
}
}

class _PlayerScoresStep extends StatelessWidget {
class _PlayerScoresStep extends StatelessWidget with EnterScoreDialogMixin {
const _PlayerScoresStep({
required this.viewModel,
Key? key,
Expand All @@ -309,7 +313,12 @@ class _PlayerScoresStep extends StatelessWidget {
child: Column(
children: [
for (var playerScore in viewModel.playerScores.values) ...[
_PlayerScore(playerScore: playerScore),
_PlayerScore(
playerScore: playerScore,
onTap: (PlayerScore playerScore) async {
await showEnterScoreDialog(context, EnterScoreViewModel(playerScore));
},
),
const SizedBox(height: Dimensions.standardSpacing),
]
],
Expand Down Expand Up @@ -666,60 +675,43 @@ class _PlayerScore extends StatelessWidget {
const _PlayerScore({
Key? key,
required this.playerScore,
required this.onTap,
}) : super(key: key);

final PlayerScore playerScore;
final void Function(PlayerScore) onTap;

@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
SizedBox(
height: Dimensions.smallPlayerAvatarSize,
width: Dimensions.smallPlayerAvatarSize,
child: PlayerAvatar(playerScore.player),
),
const SizedBox(
width: Dimensions.standardSpacing,
),
Column(
children: <Widget>[
ChangeNotifierProvider<PlayerScore>.value(
value: playerScore,
child: Consumer<PlayerScore>(
builder: (_, PlayerScore playerScoreConsumer, __) {
return NumberPicker(
value: int.tryParse(playerScoreConsumer.score.value ?? '0') ?? 0,
axis: Axis.horizontal,
itemWidth: 46,
minValue: 0,
maxValue: 10000,
onChanged: (num value) {
final String valueText = value.toString();
if (playerScoreConsumer.score.value == valueText) {
return;
}

playerScoreConsumer.updatePlayerScore(valueText);
},
selectedTextStyle: const TextStyle(
color: AppTheme.accentColor,
fontSize: Dimensions.doubleExtraLargeFontSize,
),
);
},
return InkWell(
onTap: () => onTap(playerScore),
child: Row(
children: <Widget>[
SizedBox(
height: Dimensions.smallPlayerAvatarSize,
width: Dimensions.smallPlayerAvatarSize,
child: PlayerAvatar(playerScore.player),
),
const SizedBox(width: Dimensions.doubleStandardSpacing),
Column(
children: <Widget>[
ChangeNotifierProvider<PlayerScore>.value(
value: playerScore,
child: Consumer<PlayerScore>(
builder: (_, PlayerScore playerScore, __) {
return Text(
'${playerScore.score.valueInt}',
style: Styles.playerScoreTextStyle,
);
},
),
),
),
const SizedBox(
height: Dimensions.halfStandardSpacing,
),
Text(
'points',
style: AppTheme.theme.textTheme.bodyText2,
),
],
),
],
const SizedBox(height: Dimensions.halfStandardSpacing),
Text('points', style: AppTheme.theme.textTheme.bodyText2),
],
),
],
),
);
}
}
Expand Down

0 comments on commit 39e32c2

Please sign in to comment.