Skip to content

Commit

Permalink
1.7.3 - Adding ability to edit playthrough from the history page (#150)
Browse files Browse the repository at this point in the history
* changing android's hosted agent to ubuntu

* adding ability to navigate to edit playthrough from the history list
  • Loading branch information
mkieres authored Nov 20, 2022
1 parent d2bf6a5 commit 0063ae8
Show file tree
Hide file tree
Showing 33 changed files with 457 additions and 174 deletions.
9 changes: 7 additions & 2 deletions board_games_companion/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ class BoardGamesCompanionAppState extends State<BoardGamesCompanionApp> {
case EditPlaythroughPage.pageRoute:
final arguments = routeSettings.arguments as EditPlaythroughPageArguments;
final viewModel = getIt<EditPlaythoughViewModel>();
viewModel.setBoardGameId(arguments.boardGameId);
viewModel.setPlaythroughId(arguments.playthroughId);

return MaterialPageRoute<dynamic>(
settings: routeSettings,
builder: (BuildContext context) => EditPlaythroughPage(viewModel: viewModel));
settings: routeSettings,
builder: (BuildContext context) => EditPlaythroughPage(
viewModel: viewModel,
goBackPageRoute: arguments.goBackPageRoute,
),
);

case AboutPage.pageRoute:
return MaterialPageRoute<dynamic>(
Expand Down
5 changes: 3 additions & 2 deletions board_games_companion/lib/common/app_styles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ class AppStyles {
static const double _maxOpacityDecimal = 255;
static const double _hundredPercent = 100;

static const double defaultShadowRadius = defaultCornerRadius;
static const double defaultCornerRadius = 5;
static const double defaultShadowRadius = defaultCornerRadius;
static const Offset defaultShadowOffset =
Offset(defaultCornerRadius / 2, defaultCornerRadius / 2);
static const double defaultBottomSheetCornerRadius = defaultCornerRadius * 6;
static const double defaultElevation = 4;

static const double boardGameTileImageCircularRadius = 15;
static const double boardGameTileImageShadowBlur = 1.5;
Expand All @@ -33,5 +34,5 @@ class AppStyles {
fontSize: 32,
);

static const double defaultElevation = 4;
static const double panelContainerCornerRadius = defaultCornerRadius * 3;
}
37 changes: 20 additions & 17 deletions board_games_companion/lib/injectable.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
class EditPlaythroughPageArguments {
const EditPlaythroughPageArguments(this.playthroughId, this.boardGameId);
import 'package:freezed_annotation/freezed_annotation.dart';

final String playthroughId;
final String boardGameId;
part 'edit_playthrough_page_arguments.freezed.dart';

@freezed
class EditPlaythroughPageArguments with _$EditPlaythroughPageArguments {
const factory EditPlaythroughPageArguments({
required String playthroughId,
required String boardGameId,
required String goBackPageRoute,
}) = _EditPlaythroughPageArguments;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target

part of 'edit_playthrough_page_arguments.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

/// @nodoc
mixin _$EditPlaythroughPageArguments {
String get playthroughId => throw _privateConstructorUsedError;
String get boardGameId => throw _privateConstructorUsedError;
String get goBackPageRoute => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$EditPlaythroughPageArgumentsCopyWith<EditPlaythroughPageArguments>
get copyWith => throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $EditPlaythroughPageArgumentsCopyWith<$Res> {
factory $EditPlaythroughPageArgumentsCopyWith(
EditPlaythroughPageArguments value,
$Res Function(EditPlaythroughPageArguments) then) =
_$EditPlaythroughPageArgumentsCopyWithImpl<$Res>;
$Res call({String playthroughId, String boardGameId, String goBackPageRoute});
}

/// @nodoc
class _$EditPlaythroughPageArgumentsCopyWithImpl<$Res>
implements $EditPlaythroughPageArgumentsCopyWith<$Res> {
_$EditPlaythroughPageArgumentsCopyWithImpl(this._value, this._then);

final EditPlaythroughPageArguments _value;
// ignore: unused_field
final $Res Function(EditPlaythroughPageArguments) _then;

@override
$Res call({
Object? playthroughId = freezed,
Object? boardGameId = freezed,
Object? goBackPageRoute = freezed,
}) {
return _then(_value.copyWith(
playthroughId: playthroughId == freezed
? _value.playthroughId
: playthroughId // ignore: cast_nullable_to_non_nullable
as String,
boardGameId: boardGameId == freezed
? _value.boardGameId
: boardGameId // ignore: cast_nullable_to_non_nullable
as String,
goBackPageRoute: goBackPageRoute == freezed
? _value.goBackPageRoute
: goBackPageRoute // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
abstract class _$$_EditPlaythroughPageArgumentsCopyWith<$Res>
implements $EditPlaythroughPageArgumentsCopyWith<$Res> {
factory _$$_EditPlaythroughPageArgumentsCopyWith(
_$_EditPlaythroughPageArguments value,
$Res Function(_$_EditPlaythroughPageArguments) then) =
__$$_EditPlaythroughPageArgumentsCopyWithImpl<$Res>;
@override
$Res call({String playthroughId, String boardGameId, String goBackPageRoute});
}

/// @nodoc
class __$$_EditPlaythroughPageArgumentsCopyWithImpl<$Res>
extends _$EditPlaythroughPageArgumentsCopyWithImpl<$Res>
implements _$$_EditPlaythroughPageArgumentsCopyWith<$Res> {
__$$_EditPlaythroughPageArgumentsCopyWithImpl(
_$_EditPlaythroughPageArguments _value,
$Res Function(_$_EditPlaythroughPageArguments) _then)
: super(_value, (v) => _then(v as _$_EditPlaythroughPageArguments));

@override
_$_EditPlaythroughPageArguments get _value =>
super._value as _$_EditPlaythroughPageArguments;

@override
$Res call({
Object? playthroughId = freezed,
Object? boardGameId = freezed,
Object? goBackPageRoute = freezed,
}) {
return _then(_$_EditPlaythroughPageArguments(
playthroughId: playthroughId == freezed
? _value.playthroughId
: playthroughId // ignore: cast_nullable_to_non_nullable
as String,
boardGameId: boardGameId == freezed
? _value.boardGameId
: boardGameId // ignore: cast_nullable_to_non_nullable
as String,
goBackPageRoute: goBackPageRoute == freezed
? _value.goBackPageRoute
: goBackPageRoute // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
class _$_EditPlaythroughPageArguments implements _EditPlaythroughPageArguments {
const _$_EditPlaythroughPageArguments(
{required this.playthroughId,
required this.boardGameId,
required this.goBackPageRoute});

@override
final String playthroughId;
@override
final String boardGameId;
@override
final String goBackPageRoute;

@override
String toString() {
return 'EditPlaythroughPageArguments(playthroughId: $playthroughId, boardGameId: $boardGameId, goBackPageRoute: $goBackPageRoute)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_EditPlaythroughPageArguments &&
const DeepCollectionEquality()
.equals(other.playthroughId, playthroughId) &&
const DeepCollectionEquality()
.equals(other.boardGameId, boardGameId) &&
const DeepCollectionEquality()
.equals(other.goBackPageRoute, goBackPageRoute));
}

@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(playthroughId),
const DeepCollectionEquality().hash(boardGameId),
const DeepCollectionEquality().hash(goBackPageRoute));

@JsonKey(ignore: true)
@override
_$$_EditPlaythroughPageArgumentsCopyWith<_$_EditPlaythroughPageArguments>
get copyWith => __$$_EditPlaythroughPageArgumentsCopyWithImpl<
_$_EditPlaythroughPageArguments>(this, _$identity);
}

abstract class _EditPlaythroughPageArguments
implements EditPlaythroughPageArguments {
const factory _EditPlaythroughPageArguments(
{required final String playthroughId,
required final String boardGameId,
required final String goBackPageRoute}) = _$_EditPlaythroughPageArguments;

@override
String get playthroughId;
@override
String get boardGameId;
@override
String get goBackPageRoute;
@override
@JsonKey(ignore: true)
_$$_EditPlaythroughPageArgumentsCopyWith<_$_EditPlaythroughPageArguments>
get copyWith => throw _privateConstructorUsedError;
}
1 change: 1 addition & 0 deletions board_games_companion/lib/models/player_score.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export '../extensions/player_score_extensions.dart';

part 'player_score.freezed.dart';

/// Model containing [Player] and their [Score]
@freezed
class PlayerScore with _$PlayerScore {
const factory PlayerScore({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ import '../../widgets/common/slivers/bgc_sliver_header_delegate.dart';
import '../../widgets/player/player_avatar.dart';
import '../../widgets/playthrough/calendar_card.dart';
import '../enter_score/enter_score_view_model.dart';
import '../playthroughs/playthroughs_page.dart';
import 'edit_playthrough_view_model.dart';

class EditPlaythroughPage extends StatefulWidget {
const EditPlaythroughPage({
required this.viewModel,
required this.goBackPageRoute,
Key? key,
}) : super(key: key);

static const String pageRoute = '/editPlaythrough';

final EditPlaythoughViewModel viewModel;
final String goBackPageRoute;

@override
EditPlaythroughPageState createState() => EditPlaythroughPageState();
Expand Down Expand Up @@ -183,9 +184,7 @@ class EditPlaythroughPageState extends State<EditPlaythroughPage> with EnterScor
actions: <Widget>[
TextButton(
child: const Text(AppText.cancel, style: TextStyle(color: AppColors.accentColor)),
onPressed: () {
Navigator.of(context).pop();
},
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
style: TextButton.styleFrom(backgroundColor: AppColors.redColor),
Expand All @@ -195,7 +194,7 @@ class EditPlaythroughPageState extends State<EditPlaythroughPage> with EnterScor
return;
}

Navigator.of(context).popUntil(ModalRoute.withName(PlaythroughsPage.pageRoute));
Navigator.of(context).popUntil(ModalRoute.withName(widget.goBackPageRoute));
},
child:
const Text(AppText.delete, style: TextStyle(color: AppColors.defaultTextColor)),
Expand All @@ -221,14 +220,12 @@ class EditPlaythroughPageState extends State<EditPlaythroughPage> with EnterScor
actions: <Widget>[
TextButton(
child: const Text(AppText.cancel, style: TextStyle(color: AppColors.accentColor)),
onPressed: () {
Navigator.of(context).pop();
},
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
style: TextButton.styleFrom(backgroundColor: AppColors.redColor),
onPressed: () async {
Navigator.of(context).popUntil(ModalRoute.withName(PlaythroughsPage.pageRoute));
Navigator.of(context).popUntil(ModalRoute.withName(widget.goBackPageRoute));
},
child: const Text(
AppText.editPlaythroughPageUnsavedChangesActionButtonText,
Expand All @@ -246,9 +243,7 @@ class EditPlaythroughPageState extends State<EditPlaythroughPage> with EnterScor
Future<void> _addNote() async {
await Navigator.of(context).pushNamed(
PlaythroughNotePage.pageRoute,
arguments: PlaythroughNotePageArguments(
widget.viewModel.playthrough,
),
arguments: PlaythroughNotePageArguments(widget.viewModel.playthrough),
);
widget.viewModel.refreshNotes();
}
Expand Down
Loading

0 comments on commit 0063ae8

Please sign in to comment.