Skip to content

Commit

Permalink
small fix of the player's name on the avatar (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkieres authored Sep 22, 2022
1 parent 7b2e27e commit 2a096ac
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
3 changes: 3 additions & 0 deletions board_games_companion/lib/common/app_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class AppText {
static const settingsPageBackupButtonText = 'Backup';
static const settingsPageRestireButtonText = 'Restore';
static const settingsPageBackupsListTitle = 'Backups';
static const settingsPageRestoreSucceededMessage = 'Your data has been successfully restored.';
static const settingsPageRestoreFailedMessage =
'Unfortunately we ran into a problem with restoring your data. Please try again or contact support at [email protected]';

static const gamePlaytimeFormat = '%s min';
static const gamePlayersSingularFormat = '%i players';
Expand Down
4 changes: 1 addition & 3 deletions board_games_companion/lib/pages/players/players_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ class PlayersPageState extends State<PlayersPage> {
actions: <Widget>[
TextButton(
child: const Text(AppText.cancel),
onPressed: () {
Navigator.of(context).pop(false);
},
onPressed: () => Navigator.of(context).pop(false),
),
TextButton(
style: TextButton.styleFrom(backgroundColor: AppColors.redColor),
Expand Down
37 changes: 37 additions & 0 deletions board_games_companion/lib/pages/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,22 @@ class _BackupSection extends StatefulWidget {
class _BackupSectionState extends State<_BackupSection> with TickerProviderStateMixin {
late AnimationController _fadeInAnimationController;
late AnimationController _sizeAnimationController;
late ReactionDisposer _restoreSuccessReactionDisposer;

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

_restoreSuccessReactionDisposer =
reaction((_) => widget.viewModel.visualState, (SettingsPageVisualState visualState) {
final messenger = ScaffoldMessenger.of(context);
visualState.when(
restoringFailure: (errorMessage) => _showRestoreFailureSnackbar(messenger),
initial: () {},
restoring: () {},
restoringSuccess: () => _showRestoreSuceededSnackbar(messenger));
});

widget.viewModel.loadBackups();

_fadeInAnimationController = AnimationController(
Expand All @@ -258,6 +269,7 @@ class _BackupSectionState extends State<_BackupSection> with TickerProviderState
void dispose() {
_fadeInAnimationController.dispose();
_sizeAnimationController.dispose();
_restoreSuccessReactionDisposer();

super.dispose();
}
Expand Down Expand Up @@ -364,6 +376,31 @@ class _BackupSectionState extends State<_BackupSection> with TickerProviderState
sharePositionOrigin: sharePositionOrigin,
);
}

Future<void> _showRestoreSuceededSnackbar(ScaffoldMessengerState messenger) async {
messenger.showSnackBar(
SnackBar(
behavior: SnackBarBehavior.floating,
margin: Dimensions.snackbarMargin,
content: const Text(AppText.settingsPageRestoreSucceededMessage),
action: SnackBarAction(
label: AppText.ok,
onPressed: () => messenger.hideCurrentSnackBar(reason: SnackBarClosedReason.dismiss),
),
),
);
}

Future<void> _showRestoreFailureSnackbar(ScaffoldMessengerState messenger) async {
messenger.showSnackBar(
const SnackBar(
behavior: SnackBarBehavior.floating,
margin: Dimensions.snackbarMargin,
content: Text(AppText.settingsPageRestoreFailedMessage),
duration: Duration(seconds: 10),
),
);
}
}

class _BackupFile extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,20 @@ class PlayerAvatarSubtitle extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.only(
bottom: Dimensions.halfStandardSpacing,
left: Dimensions.halfStandardSpacing,
right: Dimensions.halfStandardSpacing,
),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(
Radius.circular(AppStyles.defaultCornerRadius),
),
borderRadius: const BorderRadius.all(Radius.circular(AppStyles.defaultCornerRadius)),
color: AppColors.accentColor.withAlpha(AppStyles.opacity70Percent),
),
child: Padding(
padding: const EdgeInsets.all(
Dimensions.halfStandardSpacing,
),
padding: const EdgeInsets.all(Dimensions.halfStandardSpacing),
child: Text(
player.name ?? '',
style: const TextStyle(
color: AppColors.defaultTextColor,
),
textAlign: TextAlign.center,
style: const TextStyle(color: AppColors.defaultTextColor),
),
),
),
Expand Down

0 comments on commit 2a096ac

Please sign in to comment.