diff --git a/README.md b/README.md index f06f045..0cc6681 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# Apps Against Humanity +# Apps Against ~Humanity~ Fellowships +_Working title for 'rebrand'. The idea is to shift to a build-your-own-cards kinds of layout where users can create/import their own card sets and share them on a 'marketplace' where you can download any shared cardset. This would allow us to further de-couple the Cards Against Humanity cards and branding to better comply with the app store reviews_ A Flutter Cards Against Humanity app for Android, iOS, and Web diff --git a/lib/data/features/users/user_repository.dart b/lib/data/features/users/user_repository.dart index e7f228b..1affe6d 100644 --- a/lib/data/features/users/user_repository.dart +++ b/lib/data/features/users/user_repository.dart @@ -6,7 +6,7 @@ import 'package:appsagainsthumanity/data/features/users/model/user.dart'; import 'package:appsagainsthumanity/data/firestore.dart'; import 'package:appsagainsthumanity/internal/push.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:cloud_functions/cloud_functions.dart'; +// import 'package:cloud_functions/cloud_functions.dart'; import 'package:firebase_auth/firebase_auth.dart' as fb; import 'package:firebase_storage/firebase_storage.dart'; import 'package:google_sign_in/google_sign_in.dart'; @@ -146,7 +146,8 @@ class UserRepository { name = result.givenName; } - final fb.UserCredential _result = await _auth.signInWithCredential(credential); + final fb.UserCredential _result = + await _auth.signInWithCredential(credential); return _finishSigningInWithResult(_result, name: name); } @@ -206,9 +207,7 @@ class UserRepository { } DocumentReference _userDocument(fb.User user) { - return _db - .collection(FirebaseConstants.COLLECTION_USERS) - .doc(user.uid); + return _db.collection(FirebaseConstants.COLLECTION_USERS).doc(user.uid); } Reference _profilePhotoReference(fb.User user) { diff --git a/lib/internal/push.dart b/lib/internal/push.dart index 19aff00..e405e45 100644 --- a/lib/internal/push.dart +++ b/lib/internal/push.dart @@ -6,11 +6,11 @@ import 'package:appsagainsthumanity/data/features/game/game_repository.dart'; import 'package:appsagainsthumanity/data/features/game/model/turn.dart'; import 'package:appsagainsthumanity/internal/dynamic_links.dart'; import 'package:appsagainsthumanity/ui/routes.dart'; -import 'package:appsagainsthumanity/internal.dart'; +// import 'package:appsagainsthumanity/internal.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; +// import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:logging/logging.dart'; @@ -45,7 +45,8 @@ class PushNotifications { Future checkAndUpdateToken({bool force = false}) async { String token = await _firebaseMessaging.getToken(); if (token != AppPreferences().pushToken || force) { - Logger.root.fine("FCM Token is different from what is stored in preferences, updating device..."); + Logger.root.fine( + "FCM Token is different from what is stored in preferences, updating device..."); DeviceRepository().updatePushToken(token); } } @@ -74,7 +75,8 @@ class _PushNavigatorState extends State { }); /// let's go ahead and sign up here to handle dynamic links - DynamicLinks.initDynamicLinks(context, (gameId) => navigateToGame(gameId, andJoin: true)); + DynamicLinks.initDynamicLinks( + context, (gameId) => navigateToGame(gameId, andJoin: true)); } @override @@ -126,7 +128,7 @@ class _PushNavigatorState extends State { ..push(GamePageRoute(game)); } } else { - print("Unable to join the Game($gameId)"); + print("Unable to join the Game($gameId)"); } } catch (e) { print(e); diff --git a/lib/internal/theme.dart b/lib/internal/theme.dart index aef2271..e6becd6 100644 --- a/lib/internal/theme.dart +++ b/lib/internal/theme.dart @@ -2,170 +2,167 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class AppColors { - AppColors._(); + AppColors._(); - static const primary = Color(0xFFAB47BC); - static const primaryDark = Color(0xFF790e8b); - static const primaryVariant = Color(0xFFdf78ef); - static const colorOnPrimary = Color(0xFFFFFFFF); - static const colorOnPrimaryVariant = Color(0xDD000000); + static const primary = Color(0xFFAB47BC); + static const primaryDark = Color(0xFF790e8b); + static const primaryVariant = Color(0xFFdf78ef); + static const colorOnPrimary = Color(0xFFFFFFFF); + static const colorOnPrimaryVariant = Color(0xDD000000); - static const secondary = Color(0xFF00BCD4); - static const secondaryLight = Color(0xFF80DEEA); - static const secondaryDark = Color(0xFF006064); + static const secondary = Color(0xFF00BCD4); + static const secondaryLight = Color(0xFF80DEEA); + static const secondaryDark = Color(0xFF006064); - static const surface = Color(0xFF3C3C3C); - static const surfaceLight = Color(0xFF4F4F4F); - static const surfaceDark = Color(0xFF303030); - static const responseCardBackground = Color(0xFFF2F2F2); + static const surface = Color(0xFF3C3C3C); + static const surfaceLight = Color(0xFF4F4F4F); + static const surfaceDark = Color(0xFF303030); + static const responseCardBackground = Color(0xFFF2F2F2); - static const error = Color(0xFFFF5252); + static const error = Color(0xFFFF5252); - static const addPhotoBackground = Color(0xFF666666); - static const addPhotoForeground = Colors.white70; + static const addPhotoBackground = Color(0xFF666666); + static const addPhotoForeground = Colors.white70; } class AppThemes { - AppThemes._(); - - static ThemeData get light { - final textTheme = Typography.material2018(platform: defaultTargetPlatform).white; - return ThemeData( - brightness: Brightness.light, - primaryColor: AppColors.primary, - primaryColorDark: AppColors.primaryDark, - primaryColorLight: AppColors.primaryVariant, - accentColor: AppColors.primary, - canvasColor: AppColors.surface, - cardColor: Colors.white, - textTheme: textTheme, - iconTheme: const IconThemeData(color: Colors.white), - disabledColor: Colors.white38, - unselectedWidgetColor: Colors.white70, - dialogBackgroundColor: Colors.grey[700], - appBarTheme: AppBarTheme( - color: AppColors.surfaceDark - ), - snackBarTheme: SnackBarThemeData( - backgroundColor: AppColors.surfaceLight, - contentTextStyle: textTheme.subtitle1, - actionTextColor: AppColors.primary, - disabledActionTextColor: Colors.white30, - ), - bottomAppBarColor: AppColors.surfaceDark, - ); - } - - static ThemeData get dark => - ThemeData( - brightness: Brightness.dark, - primaryColor: AppColors.primaryVariant, - primaryColorDark: AppColors.primaryDark, - primaryColorLight: AppColors.primaryVariant, - floatingActionButtonTheme: FloatingActionButtonThemeData( - foregroundColor: Colors.white - ), - accentColor: AppColors.primaryVariant, - cardColor: Colors.grey[700], - appBarTheme: AppBarTheme( - color: AppColors.surface - ), - snackBarTheme: SnackBarThemeData( - backgroundColor: AppColors.surfaceDark, - contentTextStyle: Typography.material2018(platform: defaultTargetPlatform).white.subtitle1, - actionTextColor: AppColors.primary, - disabledActionTextColor: Colors.white30, - ), - bottomAppBarColor: AppColors.surface, - ); + AppThemes._(); + + static ThemeData get light { + final textTheme = + Typography.material2018(platform: defaultTargetPlatform).white; + return ThemeData( + brightness: Brightness.light, + primaryColor: AppColors.primary, + primaryColorDark: AppColors.primaryDark, + primaryColorLight: AppColors.primaryVariant, + accentColor: AppColors.primary, + canvasColor: AppColors.surface, + cardColor: Colors.white, + textTheme: textTheme, + iconTheme: const IconThemeData(color: Colors.white), + disabledColor: Colors.white38, + unselectedWidgetColor: Colors.white70, + dialogBackgroundColor: Colors.grey[700], + appBarTheme: AppBarTheme(color: AppColors.surfaceDark), + snackBarTheme: SnackBarThemeData( + backgroundColor: AppColors.surfaceLight, + contentTextStyle: textTheme.subtitle1, + // actionstyle: TextButton.styleFrom( + // primary: AppColors.primary, + // ), + disabledActionTextColor: Colors.white30, + ), + bottomAppBarColor: AppColors.surfaceDark, + ); + } + + static ThemeData get dark => ThemeData( + brightness: Brightness.dark, + primaryColor: AppColors.primaryVariant, + primaryColorDark: AppColors.primaryDark, + primaryColorLight: AppColors.primaryVariant, + floatingActionButtonTheme: + FloatingActionButtonThemeData(foregroundColor: Colors.white), + accentColor: AppColors.primaryVariant, + cardColor: Colors.grey[700], + appBarTheme: AppBarTheme(color: AppColors.surface), + snackBarTheme: SnackBarThemeData( + backgroundColor: AppColors.surfaceDark, + contentTextStyle: + Typography.material2018(platform: defaultTargetPlatform) + .white + .subtitle1, + // actionstyle: TextButton.styleFrom( + // primary: AppColors.primary, + // ), + disabledActionTextColor: Colors.white30, + ), + bottomAppBarColor: AppColors.surface, + ); } extension TextAppearanceExt on BuildContext { - - TextStyle cardTextStyle(Color textColor) { - final base = theme.textTheme.headline5; - final screenWidth = MediaQuery.of(this).size.width; - - double fontSize = base.fontSize; - if (screenWidth > 360 && screenWidth <= 400) { - fontSize = 20.0; // Headline 6 Size - } else if (screenWidth > 300 && screenWidth <= 360) { - fontSize = 18.0; // Subtitle 1 - } else if (screenWidth <= 300) { - fontSize = 16.0; - } - - return base.copyWith( - color: textColor, - fontSize: fontSize - ); + TextStyle cardTextStyle(Color textColor) { + final base = theme.textTheme.headline5; + final screenWidth = MediaQuery.of(this).size.width; + + double fontSize = base.fontSize; + if (screenWidth > 360 && screenWidth <= 400) { + fontSize = 20.0; // Headline 6 Size + } else if (screenWidth > 300 && screenWidth <= 360) { + fontSize = 18.0; // Subtitle 1 + } else if (screenWidth <= 300) { + fontSize = 16.0; } + + return base.copyWith(color: textColor, fontSize: fontSize); + } } extension ThemeExt on BuildContext { - - ThemeData get theme => Theme.of(this); - - Color get primaryColor { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return AppColors.primaryVariant; - } else { - return AppColors.primary; - } + ThemeData get theme => Theme.of(this); + + Color get primaryColor { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return AppColors.primaryVariant; + } else { + return AppColors.primary; } - - Color get colorOnCard { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return Colors.white; - } else { - return Colors.black87; - } + } + + Color get colorOnCard { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return Colors.white; + } else { + return Colors.black87; } - - Color get secondaryColorOnCard { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return Colors.white54; - } else { - return Colors.black38; - } + } + + Color get secondaryColorOnCard { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return Colors.white54; + } else { + return Colors.black38; } - - Color get tertiaryColorOnCard { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return Colors.white38; - } else { - return Colors.black26; - } + } + + Color get tertiaryColorOnCard { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return Colors.white38; + } else { + return Colors.black26; } - - Color get responseCardColor { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return Colors.grey[600]; - } else { - return AppColors.responseCardBackground; - } + } + + Color get responseCardColor { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return Colors.grey[600]; + } else { + return AppColors.responseCardBackground; } - - Color get responseCardHandColor { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return Colors.grey[500]; - } else { - return AppColors.responseCardBackground; - } + } + + Color get responseCardHandColor { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return Colors.grey[500]; + } else { + return AppColors.responseCardBackground; } - - Color get responseBorderColor { - var brightness = theme.brightness; - if (brightness == Brightness.dark) { - return Colors.white12; - } else { - return Colors.black12; - } + } + + Color get responseBorderColor { + var brightness = theme.brightness; + if (brightness == Brightness.dark) { + return Colors.white12; + } else { + return Colors.black12; } + } } diff --git a/lib/ui/creategame/create_game_screen.dart b/lib/ui/creategame/create_game_screen.dart index b007a52..4eae13a 100644 --- a/lib/ui/creategame/create_game_screen.dart +++ b/lib/ui/creategame/create_game_screen.dart @@ -1,5 +1,5 @@ import 'package:appsagainsthumanity/data/features/cards/model/card_set.dart'; -import 'package:appsagainsthumanity/data/features/game/game_repository.dart'; +// import 'package:appsagainsthumanity/data/features/game/game_repository.dart'; import 'package:appsagainsthumanity/ui/creategame/bloc/bloc.dart'; import 'package:appsagainsthumanity/internal.dart'; import 'package:appsagainsthumanity/ui/creategame/widgets/CountPreference.dart'; @@ -32,7 +32,7 @@ class _CreateGameScreenState extends State { condition: (previous, current) => current.error != previous.error, listener: (context, state) { if (state.error != null) { - Scaffold.of(context) + ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar( SnackBar( @@ -49,10 +49,12 @@ class _CreateGameScreenState extends State { // New Game Listener BlocListener( - condition: (previous, current) => current.createdGame?.id != previous.createdGame?.id, + condition: (previous, current) => + current.createdGame?.id != previous.createdGame?.id, listener: (context, state) { if (state.createdGame != null) { - Navigator.of(context).pushReplacement(GamePageRoute(state.createdGame)); + Navigator.of(context) + .pushReplacement(GamePageRoute(state.createdGame)); } }, ), @@ -73,7 +75,8 @@ class _CreateGameScreenState extends State { brightness: Brightness.dark, title: Text( context.strings.titleNewGame, - style: context.theme.textTheme.headline6.copyWith(color: Colors.white), + style: context.theme.textTheme.headline6 + .copyWith(color: Colors.white), ), leading: IconButton( icon: Icon(Icons.arrow_back, color: Colors.white), @@ -101,7 +104,9 @@ class _CreateGameScreenState extends State { child: Container( margin: const EdgeInsets.symmetric(horizontal: 16), child: Text( - state.isLoading ? "Loading..." : "${state.totalPrompts} Prompts ${state.totalResponses} Responses", + state.isLoading + ? "Loading..." + : "${state.totalPrompts} Prompts ${state.totalResponses} Responses", style: context.theme.textTheme.headline6, ), ), @@ -110,17 +115,20 @@ class _CreateGameScreenState extends State { ), ), ), - floatingActionButtonLocation: FloatingActionButtonLocation.endDocked, - floatingActionButton: state.selectedSets.isNotEmpty() && !state.isLoading - ? FloatingActionButton( - child: Icon(Icons.check), - onPressed: () async { - // Start game? - Analytics().logSelectContent(contentType: 'action', itemId: 'create_game'); - context.bloc().add(CreateGame()); - }, - ) - : null, + floatingActionButtonLocation: + FloatingActionButtonLocation.endDocked, + floatingActionButton: + state.selectedSets.isNotEmpty() && !state.isLoading + ? FloatingActionButton( + child: Icon(Icons.check), + onPressed: () async { + // Start game? + Analytics().logSelectContent( + contentType: 'action', itemId: 'create_game'); + context.bloc().add(CreateGame()); + }, + ) + : null, body: TabBarView( children: [ _buildCardSetLists(state), @@ -137,7 +145,9 @@ class _CreateGameScreenState extends State { return Column( children: [ Expanded( - child: state.isLoading ? _buildLoading() : _buildList(state.cardSets, state.selectedSets), + child: state.isLoading + ? _buildLoading() + : _buildList(state.cardSets, state.selectedSets), ), ], ); @@ -153,7 +163,8 @@ class _CreateGameScreenState extends State { min: 1, max: 15, onValueChanged: (value) { - Analytics().logSelectContent(contentType: 'game_option', itemId: 'prizes_to_win'); + Analytics().logSelectContent( + contentType: 'game_option', itemId: 'prizes_to_win'); context.bloc().add(ChangePrizesToWin(value)); }, ), @@ -164,7 +175,8 @@ class _CreateGameScreenState extends State { min: 5, max: 30, onValueChanged: (value) { - Analytics().logSelectContent(contentType: 'game_option', itemId: 'player_limit'); + Analytics().logSelectContent( + contentType: 'game_option', itemId: 'player_limit'); context.bloc().add(ChangePlayerLimit(value)); }, ), @@ -174,7 +186,8 @@ class _CreateGameScreenState extends State { activeColor: AppColors.primary, value: state.pick2Enabled, onChanged: (value) { - Analytics().logSelectContent(contentType: 'game_option', itemId: 'pick2'); + Analytics() + .logSelectContent(contentType: 'game_option', itemId: 'pick2'); context.bloc().add(ChangePick2Enabled(value)); }, ), @@ -184,7 +197,8 @@ class _CreateGameScreenState extends State { activeColor: AppColors.primary, value: state.draw2pick3Enabled, onChanged: (value) { - Analytics().logSelectContent(contentType: 'game_option', itemId: 'draw2_pick3'); + Analytics().logSelectContent( + contentType: 'game_option', itemId: 'draw2_pick3'); context.bloc().add(ChangeDraw2Pick3Enabled(value)); }, ), @@ -211,11 +225,19 @@ class _CreateGameScreenState extends State { return aW.compareTo(bW); } }).flatMap((key) { - var items = groupedSets.get(key).map((cs) => CardSetListItem(cs, selected.contains(cs))); + var items = groupedSets + .get(key) + .map((cs) => CardSetListItem(cs, selected.contains(cs))); var allItemsSelected = items.all((i) => i.isSelected); var noItemsSelected = items.none((i) => i.isSelected); return mutableListOf( - HeaderItem(key, allItemsSelected ? true : noItemsSelected ? false : null), + HeaderItem( + key, + allItemsSelected + ? true + : noItemsSelected + ? false + : null), )..addAll(items); }); @@ -252,8 +274,11 @@ class HeaderItem extends StatelessWidget { Widget build(BuildContext context) { return InkWell( onTap: () { - Analytics().logSelectContent(contentType: 'card_set_source', itemId: title); - context.bloc().add(CardSourceSelected(title, isChecked)); + Analytics() + .logSelectContent(contentType: 'card_set_source', itemId: title); + context + .bloc() + .add(CardSourceSelected(title, isChecked)); }, child: Column( children: [ @@ -271,8 +296,11 @@ class HeaderItem extends StatelessWidget { value: isChecked, tristate: true, onChanged: (value) { - Analytics().logSelectContent(contentType: 'card_set_source', itemId: title); - context.bloc().add(CardSourceSelected(title, value)); + Analytics().logSelectContent( + contentType: 'card_set_source', itemId: title); + context + .bloc() + .add(CardSourceSelected(title, value)); }, activeColor: AppColors.primary, checkColor: Colors.white, @@ -312,12 +340,14 @@ class CardSetListItem extends StatelessWidget { value: isSelected, activeColor: AppColors.primary, onChanged: (value) { - Analytics().logSelectContent(contentType: 'card_set', itemId: cardSet.name); + Analytics() + .logSelectContent(contentType: 'card_set', itemId: cardSet.name); context.bloc().add(CardSetSelected(cardSet)); }, ), onTap: () { - Analytics().logSelectContent(contentType: 'card_set', itemId: cardSet.name); + Analytics() + .logSelectContent(contentType: 'card_set', itemId: cardSet.name); context.bloc().add(CardSetSelected(cardSet)); }, ); diff --git a/lib/ui/game/screens/complete/completed_game_screen.dart b/lib/ui/game/screens/complete/completed_game_screen.dart index 8b4bde2..eaffaa9 100644 --- a/lib/ui/game/screens/complete/completed_game_screen.dart +++ b/lib/ui/game/screens/complete/completed_game_screen.dart @@ -47,34 +47,39 @@ class CompletedGameScreen extends StatelessWidget { Container( margin: const EdgeInsets.symmetric(horizontal: 24), width: double.maxFinite, - child: RaisedButton( + child: ElevatedButton( child: Text("NEW GAME"), - color: AppColors.primary, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8) + style: ElevatedButton.styleFrom( + primary: AppColors.primary, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8)), ), onPressed: () { - Analytics().logSelectContent(contentType: 'game', itemId: 'create_new_game'); + Analytics().logSelectContent( + contentType: 'game', itemId: 'create_new_game'); Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => CreateGameScreen() - )); + builder: (context) => CreateGameScreen())); }, ), ), Container( - margin: const EdgeInsets.only(top: 8, left: 24, right: 24, bottom: 48), + margin: const EdgeInsets.only( + top: 8, left: 24, right: 24, bottom: 48), width: double.maxFinite, - child: OutlineButton( + child: OutlinedButton( child: Text("QUIT"), - textColor: Colors.white, - borderSide: BorderSide(color: Colors.white), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), + style: OutlinedButton.styleFrom( + primary: Colors.white, + side: BorderSide(color: Colors.white), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + // highlightedBorderColor: AppColors.primary, + // splashColor: AppColors.primary, ), - highlightedBorderColor: AppColors.primary, - splashColor: AppColors.primary, onPressed: () { - Analytics().logSelectContent(contentType: 'game', itemId: 'quit'); + Analytics() + .logSelectContent(contentType: 'game', itemId: 'quit'); Navigator.of(context).pop(); }, ), diff --git a/lib/ui/game/screens/gameplay/widget/judge/judge_dredd.dart b/lib/ui/game/screens/gameplay/widget/judge/judge_dredd.dart index 67579aa..19b94a4 100644 --- a/lib/ui/game/screens/gameplay/widget/judge/judge_dredd.dart +++ b/lib/ui/game/screens/gameplay/widget/judge/judge_dredd.dart @@ -53,16 +53,19 @@ class _JudgeDreddState extends State { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - _buildPageButton(context: context, iconData: Icons.keyboard_arrow_left, isVisible: showLeft), - + _buildPageButton( + context: context, + iconData: Icons.keyboard_arrow_left, + isVisible: showLeft), if (widget.state.isSubmitting) _buildPickingWinnerIndicator(context), - if (!widget.state.isSubmitting) _buildPickWinnerButton(context), - _buildPageButton( - context: context, iconData: Icons.keyboard_arrow_right, isLeft: false, isVisible: showRight), + context: context, + iconData: Icons.keyboard_arrow_right, + isLeft: false, + isVisible: showRight), ], ); }), @@ -73,16 +76,20 @@ class _JudgeDreddState extends State { } Widget _buildPickWinnerButton(BuildContext context) { - return RaisedButton.icon( - padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), - shape: StadiumBorder(), - color: AppColors.primary, + return ElevatedButton.icon( + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + shape: StadiumBorder(), + primary: AppColors.primary, + ), onPressed: () async { var currentPlayerResponse = controller.currentPlayerResponse; if (currentPlayerResponse != null) { - Analytics().logSelectContent(contentType: 'judge', itemId: 'pick_winner'); + Analytics() + .logSelectContent(contentType: 'judge', itemId: 'pick_winner'); print("Winner selected! ${currentPlayerResponse.playerId}"); - context.bloc() + context + .bloc() .add(PickWinner(currentPlayerResponse.playerId)); } }, @@ -104,11 +111,13 @@ class _JudgeDreddState extends State { } Widget _buildPickingWinnerIndicator(BuildContext context) { - return RaisedButton.icon( - padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), - shape: StadiumBorder(), - color: AppColors.primary, - disabledColor: AppColors.primary, + return ElevatedButton.icon( + onPressed: () {}, + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + shape: StadiumBorder(), + primary: AppColors.primary, + ), icon: Container( width: 24, height: 24, @@ -159,10 +168,12 @@ class _JudgeDreddState extends State { onTap: isVisible ? () { if (isLeft) { - Analytics().logSelectContent(contentType: 'judge', itemId: 'previous_choice'); + Analytics().logSelectContent( + contentType: 'judge', itemId: 'previous_choice'); controller.prevPage(); } else { - Analytics().logSelectContent(contentType: 'judge', itemId: 'next_choice'); + Analytics().logSelectContent( + contentType: 'judge', itemId: 'next_choice'); controller.nextPage(); } } @@ -184,7 +195,8 @@ class _JudgeDreddState extends State { class JudgementController { static const double VIEWPORT_FRACTION = 0.945; - final PageController pageController = PageController(viewportFraction: VIEWPORT_FRACTION); + final PageController pageController = + PageController(viewportFraction: VIEWPORT_FRACTION); final StreamController _pageChanges = StreamController.broadcast(); PlayerResponse _currentPlayerResponse; diff --git a/lib/ui/game/screens/gameplay/widget/player_response_picker.dart b/lib/ui/game/screens/gameplay/widget/player_response_picker.dart index a160473..b6651ea 100644 --- a/lib/ui/game/screens/gameplay/widget/player_response_picker.dart +++ b/lib/ui/game/screens/gameplay/widget/player_response_picker.dart @@ -11,7 +11,8 @@ class PlayerResponsePicker extends StatefulWidget { } class _PlayerResponsePickerState extends State { - final PageController _pageController = PageController(viewportFraction: 0.945); + final PageController _pageController = + PageController(viewportFraction: 0.945); @override Widget build(BuildContext context) { @@ -19,7 +20,6 @@ class _PlayerResponsePickerState extends State { builder: (context, state) { // Determine if we need to show the response picker, or to hide this part if (!state.areWeJudge && !state.haveWeSubmittedResponse) { - // Get the player's current hand, omitting any card's they MAY have submitted var hand = state.currentHand.reversed.toList(); return Stack( @@ -65,11 +65,12 @@ class _PlayerResponsePickerState extends State { } Widget _buildSubmittingWidget(BuildContext context) { - return RaisedButton.icon( - padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), - shape: StadiumBorder(), - color: AppColors.primary, - disabledColor: AppColors.primary, + return ElevatedButton.icon( + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + shape: StadiumBorder(), + primary: AppColors.primary, + ), onPressed: null, icon: Container( width: 24, @@ -92,12 +93,15 @@ class _PlayerResponsePickerState extends State { } Widget _buildSubmitCardsButton(BuildContext context) { - return RaisedButton.icon( - padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), - shape: StadiumBorder(), - color: AppColors.primary, + return ElevatedButton.icon( + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16), + shape: StadiumBorder(), + primary: AppColors.primary, + ), onPressed: () async { - Analytics().logSelectContent(contentType: 'action', itemId: 'submit_responses'); + Analytics().logSelectContent( + contentType: 'action', itemId: 'submit_responses'); context.bloc().add(SubmitResponses()); }, icon: Icon( @@ -152,7 +156,8 @@ class HandCard extends StatelessWidget { highlightColor: AppColors.primary.withOpacity(0.26), splashColor: AppColors.primary.withOpacity(0.26), onTap: () { - Analytics().logSelectContent(contentType: 'action', itemId: 'picked_response'); + Analytics().logSelectContent( + contentType: 'action', itemId: 'picked_response'); context.bloc().add(PickResponseCard(card)); }, child: Column( diff --git a/lib/ui/game/screens/gameplay/widget/prompt_container.dart b/lib/ui/game/screens/gameplay/widget/prompt_container.dart index 83b4dfa..e6db47e 100644 --- a/lib/ui/game/screens/gameplay/widget/prompt_container.dart +++ b/lib/ui/game/screens/gameplay/widget/prompt_container.dart @@ -83,8 +83,9 @@ class PromptContainer extends StatelessWidget { alignment: Alignment.topCenter, child: Text( "Clear Responses".toUpperCase(), - style: context.theme.textTheme.subtitle1 - .copyWith(color: context.primaryColor, fontWeight: FontWeight.w600), + style: context.theme.textTheme.subtitle1.copyWith( + color: context.primaryColor, + fontWeight: FontWeight.w600), ), ), Container( @@ -97,7 +98,8 @@ class PromptContainer extends StatelessWidget { ], ), onDismissed: (direction) { - Analytics().logSelectContent(contentType: 'action', itemId: 'clear_choices'); + Analytics().logSelectContent( + contentType: 'action', itemId: 'clear_choices'); context.bloc().add(ClearPickedResponseCards()); }, child: Container( @@ -114,7 +116,9 @@ class PromptContainer extends StatelessWidget { } Widget _buildPromptSpecial(BuildContext context, PromptCard promptCard) { - if (promptCard != null && promptCard.special != null && promptCard.special.isNotEmpty) { + if (promptCard != null && + promptCard.special != null && + promptCard.special.isNotEmpty) { return Container( height: 36, alignment: Alignment.centerRight, @@ -151,15 +155,17 @@ class PromptContainer extends StatelessWidget { Widget _buildPromptText(BuildContext context, GameViewState state) { return GestureDetector( onLongPress: () { - Analytics().logSelectContent(contentType: 'action', itemId: 'view_prompt_source'); - Scaffold.of(context).showSnackBar(SnackBar( + Analytics().logSelectContent( + contentType: 'action', itemId: 'view_prompt_source'); + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text(state.game?.turn?.promptCard?.set ?? ""), behavior: SnackBarBehavior.floating, )); }, child: Container( width: double.maxFinite, - margin: const EdgeInsets.symmetric(vertical: textPadding, horizontal: textPadding + 16), + margin: const EdgeInsets.symmetric( + vertical: textPadding, horizontal: textPadding + 16), child: BlocBuilder( builder: (context, state) { return Text( diff --git a/lib/ui/game/screens/gameplay/widget/re_deal_button.dart b/lib/ui/game/screens/gameplay/widget/re_deal_button.dart index abcc7e1..813081f 100644 --- a/lib/ui/game/screens/gameplay/widget/re_deal_button.dart +++ b/lib/ui/game/screens/gameplay/widget/re_deal_button.dart @@ -10,7 +10,9 @@ class ReDealButton extends StatelessWidget { Widget build(BuildContext context) { return BlocBuilder( builder: (context, state) { - if (!state.areWeJudge && !state.haveWeSubmittedResponse && (state.currentPlayer?.prizes?.length ?? 0) > 0) { + if (!state.areWeJudge && + !state.haveWeSubmittedResponse && + (state.currentPlayer?.prizes?.length ?? 0) > 0) { return IconButton( icon: Icon(MdiIcons.cardsVariant), tooltip: "Re-deal your hand", @@ -27,22 +29,27 @@ class ReDealButton extends StatelessWidget { content: RichText( text: TextSpan(text: 'Spend ', children: [ TextSpan( - text: '1 of ${state.currentPlayer.prizes.length} prize cards', + text: + '1 of ${state.currentPlayer.prizes.length} prize cards', style: TextStyle(fontWeight: FontWeight.bold)), TextSpan(text: ' to deal you a new hand?') ]), ), actions: [ - FlatButton( + TextButton( child: Text('CANCEL'), - textColor: AppColors.secondary, + style: TextButton.styleFrom( + primary: AppColors.secondary, + ), onPressed: () { Navigator.of(context).pop(false); }, ), - FlatButton( + TextButton( child: Text('DEAL'), - textColor: AppColors.secondary, + style: TextButton.styleFrom( + primary: AppColors.secondary, + ), onPressed: () { Navigator.of(context).pop(true); }, @@ -51,8 +58,11 @@ class ReDealButton extends StatelessWidget { ); }); if (result ?? false) { - Analytics().logSelectContent(contentType: 'action', itemId: 'redeal_hand'); - await context.repository().reDealHand(state.game.id); + Analytics().logSelectContent( + contentType: 'action', itemId: 'redeal_hand'); + await context + .repository() + .reDealHand(state.game.id); } }, ); diff --git a/lib/ui/game/screens/gameplay/widget/winning/prompt_card_view.dart b/lib/ui/game/screens/gameplay/widget/winning/prompt_card_view.dart index 46844b7..de2495a 100644 --- a/lib/ui/game/screens/gameplay/widget/winning/prompt_card_view.dart +++ b/lib/ui/game/screens/gameplay/widget/winning/prompt_card_view.dart @@ -1,12 +1,12 @@ import 'package:appsagainsthumanity/data/features/cards/model/prompt_card.dart'; import 'package:appsagainsthumanity/ui/game/bloc/bloc.dart'; import 'package:appsagainsthumanity/internal.dart'; -import 'package:appsagainsthumanity/ui/game/screens/gameplay/widget/judge/judge_dredd.dart'; -import 'package:appsagainsthumanity/ui/game/screens/gameplay/widget/response_card_view.dart'; -import 'package:appsagainsthumanity/ui/game/screens/gameplay/widget/waiting_player_responses.dart'; +// import 'package:appsagainsthumanity/ui/game/screens/gameplay/widget/judge/judge_dredd.dart'; +// import 'package:appsagainsthumanity/ui/game/screens/gameplay/widget/response_card_view.dart'; +// import 'package:appsagainsthumanity/ui/game/screens/gameplay/widget/waiting_player_responses.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; +// import 'package:flutter_bloc/flutter_bloc.dart'; +// import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; class PromptCardView extends StatelessWidget { static const textPadding = 20.0; @@ -15,8 +15,9 @@ class PromptCardView extends StatelessWidget { final Widget child; final EdgeInsets margin; - PromptCardView({@required this.state, @required this.child, EdgeInsets margin}) : - margin = margin ?? const EdgeInsets.symmetric(horizontal: 16); + PromptCardView( + {@required this.state, @required this.child, EdgeInsets margin}) + : margin = margin ?? const EdgeInsets.symmetric(horizontal: 16); @override Widget build(BuildContext context) { @@ -49,7 +50,8 @@ class PromptCardView extends StatelessWidget { ); } - Widget _buildPromptBackground({@required BuildContext context, @required PromptCard card}) { + Widget _buildPromptBackground( + {@required BuildContext context, @required PromptCard card}) { return Container( margin: margin, child: Material( @@ -69,15 +71,18 @@ class PromptCardView extends StatelessWidget { Widget _buildPromptText(BuildContext context, GameViewState state) { return GestureDetector( onLongPress: () { - Analytics().logSelectContent(contentType: 'action', itemId: 'view_prompt_source'); - Scaffold.of(context).showSnackBar(SnackBar( + Analytics().logSelectContent( + contentType: 'action', itemId: 'view_prompt_source'); + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text(state.game?.turn?.winner?.promptCard?.set ?? ""), behavior: SnackBarBehavior.floating, )); }, child: Container( width: double.maxFinite, - margin: const EdgeInsets.symmetric(vertical: textPadding, horizontal: textPadding).add(margin), + margin: const EdgeInsets.symmetric( + vertical: textPadding, horizontal: textPadding) + .add(margin), child: Text( state.lastPromptText, style: context.cardTextStyle(Colors.white), diff --git a/lib/ui/game/screens/waiting/waiting_room_screen.dart b/lib/ui/game/screens/waiting/waiting_room_screen.dart index d3b7698..aa22858 100644 --- a/lib/ui/game/screens/waiting/waiting_room_screen.dart +++ b/lib/ui/game/screens/waiting/waiting_room_screen.dart @@ -56,7 +56,6 @@ class WaitingRoomScreen extends StatelessWidget { ], ), ), - Expanded( child: Row( mainAxisSize: MainAxisSize.max, @@ -64,16 +63,22 @@ class WaitingRoomScreen extends StatelessWidget { children: [ Container( margin: const EdgeInsets.only(right: 16, top: 4), - child: OutlineButton( + child: OutlinedButton( child: Text("INVITE"), - color: context.primaryColor, - textColor: context.primaryColor, - highlightedBorderColor: context.primaryColor, - splashColor: context.primaryColor.withOpacity(0.40), - borderSide: BorderSide(color: context.primaryColor), + style: OutlinedButton.styleFrom( + primary: context.primaryColor, + // textColor: context.primaryColor, + side: BorderSide(color: context.primaryColor), + // highlightedBorderColor: context.primaryColor, + // splashColor: context.primaryColor.withOpacity(0.40), + ), onPressed: () async { - Analytics().logShare(contentType: 'game', itemId: 'invite', method: 'dynamic_link'); - var link = await DynamicLinks.createLink(state.game.id); + Analytics().logShare( + contentType: 'game', + itemId: 'invite', + method: 'dynamic_link'); + var link = + await DynamicLinks.createLink(state.game.id); await Share.share(link.toString()); }, ), @@ -102,16 +107,16 @@ class WaitingRoomScreen extends StatelessWidget { label: Text("START GAME"), backgroundColor: AppColors.primary, onPressed: () async { - Analytics().logSelectContent(contentType: 'action', itemId: 'start_game'); - context.bloc() - .add(StartGame()); + Analytics().logSelectContent( + contentType: 'action', itemId: 'start_game'); + context.bloc().add(StartGame()); }) : null, body: BlocListener( bloc: context.bloc(), listener: (context, state) { if (state.error != null) { - Scaffold.of(context) + ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar( SnackBar( @@ -130,10 +135,14 @@ class WaitingRoomScreen extends StatelessWidget { /// that needs to update to the change in game state Widget _buildPlayerList(BuildContext context, GameViewState state) { var players = state.players ?? []; - var hasRandoBeenInvitedOrNotOwner = (state.players?.any((element) => element.isRandoCardrissian) ?? false) || !state.isOurGame; + var hasRandoBeenInvitedOrNotOwner = + (state.players?.any((element) => element.isRandoCardrissian) ?? + false) || + !state.isOurGame; return ListView.builder( padding: const EdgeInsets.symmetric(vertical: 8), - itemCount: hasRandoBeenInvitedOrNotOwner ? players.length : players.length + 1, + itemCount: + hasRandoBeenInvitedOrNotOwner ? players.length : players.length + 1, itemBuilder: (context, index) { if (index < players.length) { var player = players[index]; @@ -154,13 +163,14 @@ class WaitingRoomScreen extends StatelessWidget { onTap: () {}, title: Text( playerName, - style: context.theme.textTheme.subtitle1.copyWith(color: Colors.white), + style: + context.theme.textTheme.subtitle1.copyWith(color: Colors.white), ), - leading: PlayerCircleAvatar(player: player) - ); + leading: PlayerCircleAvatar(player: player)); } - Widget _buildRandoCardrissianInvite(BuildContext context, String gameDocumentId) { + Widget _buildRandoCardrissianInvite( + BuildContext context, String gameDocumentId) { return ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 4), title: Text( @@ -175,8 +185,10 @@ class WaitingRoomScreen extends StatelessWidget { ), trailing: Icon(MdiIcons.robot, color: Colors.white), onTap: () async { - Analytics().logSelectContent(contentType: 'players', itemId: 'invite_rando_cardrissian'); - await context.repository() + Analytics().logSelectContent( + contentType: 'players', itemId: 'invite_rando_cardrissian'); + await context + .repository() .addRandoCardrissian(gameDocumentId); }, ); diff --git a/lib/ui/home/home_screen_v2.dart b/lib/ui/home/home_screen_v2.dart index 67588e8..6e86f43 100644 --- a/lib/ui/home/home_screen_v2.dart +++ b/lib/ui/home/home_screen_v2.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +// import 'dart:io'; import 'package:appsagainsthumanity/internal/push.dart'; import 'package:appsagainsthumanity/ui/creategame/create_game_screen.dart'; @@ -25,15 +25,17 @@ class _HomeScreenV2State extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => HomeBloc(context.repository(), context.repository())..add(HomeStarted()), + create: (context) => HomeBloc(context.repository(), context.repository()) + ..add(HomeStarted()), child: MultiBlocListener( listeners: [ // Error Listener BlocListener( - condition: (previous, current) => previous.error != current.error && current.error != null, + condition: (previous, current) => + previous.error != current.error && current.error != null, listener: (context, state) { if (state.error != null) { - Scaffold.of(context) + ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar( SnackBar( @@ -50,7 +52,8 @@ class _HomeScreenV2State extends State { // Joined Game listener that opens a 'joined' game BlocListener( - condition: (previous, current) => previous.joinedGame?.id != current.joinedGame?.id, + condition: (previous, current) => + previous.joinedGame?.id != current.joinedGame?.id, listener: (context, state) { if (state.joinedGame != null) { Navigator.of(context).push(GamePageRoute(state.joinedGame)); @@ -76,7 +79,6 @@ class _HomeScreenV2State extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Title Container( margin: const EdgeInsets.only(left: 24, right: 24), @@ -103,8 +105,10 @@ class _HomeScreenV2State extends State { UserWidget( state: state, onTap: () { - Analytics().logSelectContent(contentType: 'action', itemId: 'profile'); - Navigator.of(context).push(MaterialPageRoute(builder: (_) => ProfileScreen())); + Analytics().logSelectContent( + contentType: 'action', itemId: 'profile'); + Navigator.of(context).push(MaterialPageRoute( + builder: (_) => ProfileScreen())); }, ), HomeOutlineButton( @@ -113,11 +117,16 @@ class _HomeScreenV2State extends State { color: AppColors.primaryVariant, ), text: "New Game", - onTap: state.joiningGame == null ? () { - Analytics().logSelectContent(contentType: 'action', itemId: 'start_game'); - PushNotifications().checkPermissions(); - Navigator.of(context).push(MaterialPageRoute(builder: (context) => CreateGameScreen())); - } : null, + onTap: state.joiningGame == null + ? () { + Analytics().logSelectContent( + contentType: 'action', + itemId: 'start_game'); + PushNotifications().checkPermissions(); + Navigator.of(context).push(MaterialPageRoute( + builder: (context) => CreateGameScreen())); + } + : null, ), JoinGameWidget(state), ], diff --git a/lib/ui/home/widgets/home_outline_button.dart b/lib/ui/home/widgets/home_outline_button.dart index 3451c96..f95dadd 100644 --- a/lib/ui/home/widgets/home_outline_button.dart +++ b/lib/ui/home/widgets/home_outline_button.dart @@ -1,4 +1,4 @@ -import 'package:appsagainsthumanity/app.dart'; +// import 'package:appsagainsthumanity/app.dart'; import 'package:flutter/material.dart'; import 'package:appsagainsthumanity/internal.dart'; @@ -13,7 +13,7 @@ class HomeOutlineButton extends StatelessWidget { @required this.icon, @required this.text, this.textColor = AppColors.primaryVariant, - this.borderColor = AppColors.primaryVariant, + this.borderColor = AppColors.primaryVariant, this.onTap, }); diff --git a/lib/ui/home/widgets/join_room_dialog.dart b/lib/ui/home/widgets/join_room_dialog.dart index e0d11b4..b241ed5 100644 --- a/lib/ui/home/widgets/join_room_dialog.dart +++ b/lib/ui/home/widgets/join_room_dialog.dart @@ -1,8 +1,9 @@ -import 'dart:io'; +// import 'dart:io'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:appsagainsthumanity/data/firestore.dart'; import 'package:appsagainsthumanity/internal.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; class JoinRoomDialog extends StatefulWidget { @override @@ -25,18 +26,17 @@ class _JoinRoomDialogState extends State { mainAxisSize: MainAxisSize.min, children: [ Container( - margin: const EdgeInsets.only(left: 24, right: 24, top: 24), + margin: const EdgeInsets.only(left: 24, right: 24, top: 24), child: Form( key: _formKey, child: TextFormField( controller: _gameInputController, decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Game ID', - labelStyle: context.theme.textTheme.caption - ), + border: OutlineInputBorder(), + labelText: 'Game ID', + labelStyle: context.theme.textTheme.caption), maxLength: FirebaseConstants.MAX_GID_SIZE, - maxLengthEnforced: true, + maxLengthEnforcement: MaxLengthEnforcement.enforced, keyboardType: TextInputType.text, autofocus: true, textCapitalization: TextCapitalization.characters, @@ -54,20 +54,24 @@ class _JoinRoomDialogState extends State { ), ), Container( - margin: const EdgeInsets.only(bottom: 8, top: 8), + margin: const EdgeInsets.only(bottom: 8, top: 8), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - FlatButton( + TextButton( child: Text('CANCEL'), - textColor: AppColors.primary, + style: TextButton.styleFrom( + primary: AppColors.primary, + ), onPressed: () { Navigator.of(context).pop(); }, ), - FlatButton( + TextButton( child: Text('JOIN'), - textColor: AppColors.primary, + style: TextButton.styleFrom( + primary: AppColors.primary, + ), onPressed: () { if (_formKey.currentState.validate()) { var gameId = _gameInputController.text; @@ -93,7 +97,8 @@ Future showJoinRoomDialog(BuildContext context) { child: AlertDialog( title: Text('Join a game'), content: JoinRoomDialog(), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16)), contentPadding: const EdgeInsets.all(0), ), ); @@ -107,7 +112,8 @@ Future showJoinRoomDialog(BuildContext context) { child: AlertDialog( title: Text('Join a game'), content: JoinRoomDialog(), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16)), contentPadding: const EdgeInsets.all(0), ), ); diff --git a/lib/ui/home/widgets/past_game.dart b/lib/ui/home/widgets/past_game.dart index cc279ef..cbc7a7d 100644 --- a/lib/ui/home/widgets/past_game.dart +++ b/lib/ui/home/widgets/past_game.dart @@ -10,116 +10,126 @@ import 'package:material_design_icons_flutter/material_design_icons_flutter.dart import 'package:timeago/timeago.dart' as timeago; class PastGame extends StatelessWidget { - final UserGame game; - final bool isLeavingGame; + final UserGame game; + final bool isLeavingGame; - PastGame(this.game, this.isLeavingGame); + PastGame(this.game, this.isLeavingGame); - @override - Widget build(BuildContext context) { - return Dismissible( - key: Key(game.id), - child: _buildListTile(context), - direction: DismissDirection.horizontal, - background: _buildBackground(context), - confirmDismiss: (_) => confirmDismiss(context), - onDismissed: (direction) { - Analytics().logSelectContent(contentType: 'past_game', itemId: 'leave'); - context.bloc().add(LeaveGame(game)); - }, - ); - } + @override + Widget build(BuildContext context) { + return Dismissible( + key: Key(game.id), + child: _buildListTile(context), + direction: DismissDirection.horizontal, + background: _buildBackground(context), + confirmDismiss: (_) => confirmDismiss(context), + onDismissed: (direction) { + Analytics().logSelectContent(contentType: 'past_game', itemId: 'leave'); + context.bloc().add(LeaveGame(game)); + }, + ); + } - Widget _buildListTile(BuildContext context) { - return ListTile( - contentPadding: const EdgeInsets.symmetric(horizontal: 24), - title: Text( - game.gid, - style: context.theme.textTheme.subtitle1.copyWith( - color: AppColors.primaryVariant, - fontWeight: FontWeight.w500, - ), + Widget _buildListTile(BuildContext context) { + return ListTile( + contentPadding: const EdgeInsets.symmetric(horizontal: 24), + title: Text( + game.gid, + style: context.theme.textTheme.subtitle1.copyWith( + color: AppColors.primaryVariant, + fontWeight: FontWeight.w500, + ), + ), + subtitle: Text( + isLeavingGame ? "Leaving..." : game.state.label, + style: context.theme.textTheme.bodyText2.copyWith( + color: Colors.white60, + ), + ), + trailing: isLeavingGame + ? Container(width: 24, height: 24, child: CircularProgressIndicator()) + : Text( + timeago.format(game.joinedAt), + style: context.theme.textTheme.bodyText2.copyWith( + color: Colors.white54, + ), ), - subtitle: Text( - isLeavingGame ? "Leaving..." : game.state.label, - style: context.theme.textTheme.bodyText2.copyWith( - color: Colors.white60, - ), + onTap: game.state == GameState.inProgress || + game.state == GameState.waitingRoom + ? () => openGame(context) + : null, + ); + } + + Widget _buildBackground(BuildContext context) { + return Container( + color: Colors.redAccent[200], + child: Row( + children: [ + Container( + margin: const EdgeInsets.only(left: 16), + child: Icon( + MdiIcons.deleteEmpty, + color: Colors.white, ), - trailing: isLeavingGame - ? Container(width: 24, height: 24, child: CircularProgressIndicator()) - : Text( - timeago.format(game.joinedAt), - style: context.theme.textTheme.bodyText2.copyWith( - color: Colors.white54, - ), + ), + Expanded( + child: Container(), + ), + Container( + margin: const EdgeInsets.only(right: 16), + child: Icon( + MdiIcons.deleteEmpty, + color: Colors.white, ), - onTap: game.state == GameState.inProgress || game.state == GameState.waitingRoom ? () => openGame(context) : null, - ); - } - - Widget _buildBackground(BuildContext context) { - return Container( - color: Colors.redAccent[200], - child: Row( - children: [ - Container( - margin: const EdgeInsets.only(left: 16), - child: Icon( - MdiIcons.deleteEmpty, - color: Colors.white, - ), - ), - Expanded( - child: Container(), - ), - Container( - margin: const EdgeInsets.only(right: 16), - child: Icon( - MdiIcons.deleteEmpty, - color: Colors.white, - ), - ), - ], ), - ); - } + ], + ), + ); + } - void openGame(BuildContext context) async { - Analytics().logSelectContent(contentType: 'past_game', itemId: 'open'); - try { - var existingGame = await context.repository().getGame(game.id); - Navigator.of(context).push(GamePageRoute(existingGame)); - } catch (e) { - Scaffold.of(context) - ..hideCurrentSnackBar() - ..showSnackBar(SnackBar( - content: Text("$e"), - )); - } + void openGame(BuildContext context) async { + Analytics().logSelectContent(contentType: 'past_game', itemId: 'open'); + try { + var existingGame = + await context.repository().getGame(game.id); + Navigator.of(context).push(GamePageRoute(existingGame)); + } catch (e) { + ScaffoldMessenger.of(context) + ..hideCurrentSnackBar() + ..showSnackBar(SnackBar( + content: Text("$e"), + )); } + } - Future confirmDismiss(BuildContext context) { - return showDialog( - context: context, - builder: (context) { - return AlertDialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), - title: Text("Leave game?"), - content: Text("Are you sure you want to leave the game ${game.gid}?"), - actions: [ - FlatButton( - child: Text("CANCEL"), - textColor: AppColors.primaryVariant, - onPressed: () => Navigator.of(context).pop(false), - ), - FlatButton( - child: Text("LEAVE"), - textColor: AppColors.primaryVariant, - onPressed: () => Navigator.of(context).pop(true), - ), - ], - ); - }); - } + Future confirmDismiss(BuildContext context) { + return showDialog( + context: context, + builder: (context) { + return AlertDialog( + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + title: Text("Leave game?"), + content: + Text("Are you sure you want to leave the game ${game.gid}?"), + actions: [ + TextButton( + child: Text("CANCEL"), + style: TextButton.styleFrom( + primary: AppColors.primaryVariant, + ), + onPressed: () => Navigator.of(context).pop(false), + ), + TextButton( + child: Text("LEAVE"), + style: TextButton.styleFrom( + primary: AppColors.primaryVariant, + ), + onPressed: () => Navigator.of(context).pop(true), + ), + ], + ); + }); + } } diff --git a/lib/ui/settings/settings_screen.dart b/lib/ui/settings/settings_screen.dart index 93d967e..c72963f 100644 --- a/lib/ui/settings/settings_screen.dart +++ b/lib/ui/settings/settings_screen.dart @@ -30,7 +30,8 @@ class _SettingsScreenState extends State { appBar: AppBar( title: Text( "Settings", - style: context.theme.textTheme.headline6.copyWith(color: Colors.white), + style: + context.theme.textTheme.headline6.copyWith(color: Colors.white), ), iconTheme: context.theme.iconTheme, backgroundColor: Colors.transparent, @@ -44,8 +45,10 @@ class _SettingsScreenState extends State { children: [ UserPreference( onTap: (user) { - Analytics().logSelectContent(contentType: 'setting', itemId: 'profile'); - Navigator.of(context).push(MaterialPageRoute(builder: (_) => ProfileScreen())); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'profile'); + Navigator.of(context) + .push(MaterialPageRoute(builder: (_) => ProfileScreen())); }, ), Preference( @@ -82,7 +85,8 @@ class _SettingsScreenState extends State { color: context.secondaryColorOnCard, ), onTap: () { - Analytics().logSelectContent(contentType: 'setting', itemId: 'privacy_policy'); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'privacy_policy'); showWebView( context, "Privacy Policy", @@ -97,7 +101,8 @@ class _SettingsScreenState extends State { color: context.secondaryColorOnCard, ), onTap: () { - Analytics().logSelectContent(contentType: 'setting', itemId: 'terms_of_service'); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'terms_of_service'); showWebView( context, "Terms of service", @@ -112,7 +117,8 @@ class _SettingsScreenState extends State { color: context.secondaryColorOnCard, ), onTap: () { - Analytics().logSelectContent(contentType: 'setting', itemId: 'oss_licenses'); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'oss_licenses'); showLicensePage(context: context); }, ), @@ -124,9 +130,11 @@ class _SettingsScreenState extends State { Preference( title: "Feedback", subtitle: "Provide feedback on issues or improvements", - icon: Icon(MdiIcons.faceAgent, color: context.secondaryColorOnCard), + icon: Icon(MdiIcons.faceAgent, + color: context.secondaryColorOnCard), onTap: () { - Analytics().logSelectContent(contentType: 'setting', itemId: 'feedback'); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'feedback'); Wiredash.of(context).show(); }, ), @@ -138,7 +146,8 @@ class _SettingsScreenState extends State { color: context.secondaryColorOnCard, ), onTap: () { - Analytics().logSelectContent(contentType: 'setting', itemId: 'contribute'); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'contribute'); showWebView( context, "Contribute", @@ -153,7 +162,8 @@ class _SettingsScreenState extends State { color: context.secondaryColorOnCard, ), onTap: () { - Analytics().logSelectContent(contentType: 'setting', itemId: 'author'); + Analytics().logSelectContent( + contentType: 'setting', itemId: 'author'); showWebView( context, "52inc", @@ -169,18 +179,21 @@ class _SettingsScreenState extends State { threshold: 5, onTapCountReachedCallback: () { if (!AppPreferences().developerPackEnabled) { - Analytics().logSelectContent(contentType: 'setting', itemId: 'developer_packs'); + Analytics().logSelectContent( + contentType: 'setting', + itemId: 'developer_packs'); AppPreferences().developerPackEnabled = true; setState(() {}); - Scaffold.of(context).showSnackBar(SnackBar( + ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Developer Packs Unlocked!"), behavior: SnackBarBehavior.floating, action: SnackBarAction( label: "VIEW", textColor: context.primaryColor, onPressed: () { - Navigator.of(context) - .pushReplacement(MaterialPageRoute(builder: (_) => CreateGameScreen())); + Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (_) => CreateGameScreen())); }, ), )); @@ -192,8 +205,9 @@ class _SettingsScreenState extends State { MdiIcons.application, color: context.secondaryColorOnCard, ), - subtitle: - packageInfo != null ? "${packageInfo.version}+${packageInfo.buildNumber}" : "Loading...", + subtitle: packageInfo != null + ? "${packageInfo.version}+${packageInfo.buildNumber}" + : "Loading...", ), ); }), @@ -221,11 +235,13 @@ class _SettingsScreenState extends State { trailing: AppPreferences().developerPackEnabled ? Text( "ENABLED", - style: context.theme.textTheme.button.copyWith(color: Colors.green), + style: context.theme.textTheme.button + .copyWith(color: Colors.green), ) : Text( "DISABLED", - style: context.theme.textTheme.button.copyWith(color: Colors.redAccent), + style: context.theme.textTheme.button + .copyWith(color: Colors.redAccent), ), icon: Image.asset( 'assets/ic_logo.png', @@ -241,7 +257,8 @@ class _SettingsScreenState extends State { children: [ GestureDetector( onTap: () { - showWebView(context, "Cards Against Humanity", "https://cardsagainsthumanity.com"); + showWebView(context, "Cards Against Humanity", + "https://cardsagainsthumanity.com"); }, child: Container( child: Text( @@ -257,8 +274,8 @@ class _SettingsScreenState extends State { margin: const EdgeInsets.only(top: 16), child: GestureDetector( onTap: () { - showWebView( - context, "CC BY-NC-SA 4.0", "https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode"); + showWebView(context, "CC BY-NC-SA 4.0", + "https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode"); }, child: Image.asset( 'assets/cc_by_nc_sa.png', @@ -279,10 +296,12 @@ class _SettingsScreenState extends State { context: context, builder: (context) { return AlertDialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), title: Text( "Delete account?", - style: context.theme.textTheme.headline6.copyWith(color: Colors.redAccent), + style: context.theme.textTheme.headline6 + .copyWith(color: Colors.redAccent), ), content: Text( "Are you sure you want to delete your account? This is permenant and cannot be undone.", @@ -291,16 +310,20 @@ class _SettingsScreenState extends State { ), ), actions: [ - FlatButton( + TextButton( child: Text("CANCEL"), - textColor: Colors.white70, + style: TextButton.styleFrom( + primary: Colors.white70, + ), onPressed: () { Navigator.of(context).pop(false); }, ), - FlatButton( + TextButton( child: Text("DELETE ACCOUNT"), - textColor: Colors.redAccent, + style: TextButton.styleFrom( + primary: Colors.redAccent, + ), onPressed: () { Navigator.of(context).pop(true); }, @@ -310,7 +333,8 @@ class _SettingsScreenState extends State { }); if (result ?? false) { - Analytics().logSelectContent(contentType: 'setting', itemId: 'delete_account'); + Analytics() + .logSelectContent(contentType: 'setting', itemId: 'delete_account'); var userRepository = context.repository(); try { await userRepository.deleteAccount(); @@ -360,7 +384,8 @@ class PreferenceCategory extends StatelessWidget { padding: const EdgeInsets.only(bottom: 8), child: Column( children: [ - if (title != null) PreferenceHeader(title: title, includeIconSpacing: false), + if (title != null) + PreferenceHeader(title: title, includeIconSpacing: false), ...children, ], ), diff --git a/lib/ui/signin/sign_in_screen.dart b/lib/ui/signin/sign_in_screen.dart index be2f99b..29bdeb9 100644 --- a/lib/ui/signin/sign_in_screen.dart +++ b/lib/ui/signin/sign_in_screen.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +// import 'dart:io'; import 'package:appsagainsthumanity/authentication_bloc/authentication_bloc.dart'; import 'package:appsagainsthumanity/internal.dart'; @@ -36,7 +36,7 @@ class _SignInScreen extends State { return BlocConsumer( listener: (context, state) { if (state.isFailure) { - Scaffold.of(context) + ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar( SnackBar( @@ -133,8 +133,7 @@ class _SignInScreen extends State { borderRadius: BorderRadius.circular(6), child: InkWell( onTap: () { - context.bloc() - .add(LoginWithGooglePressed()); + context.bloc().add(LoginWithGooglePressed()); }, child: Container( width: double.maxFinite, diff --git a/lib/ui/terms_screen.dart b/lib/ui/terms_screen.dart index 8b1fee1..4cfadff 100644 --- a/lib/ui/terms_screen.dart +++ b/lib/ui/terms_screen.dart @@ -48,45 +48,45 @@ class _TermsOfServiceScreenState extends State { }, ), ), - StreamBuilder( - stream: _loadingStream.stream, - builder: (context, snapshot) { - if (snapshot.data ?? false) { - return Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - child: CircularProgressIndicator(), - ), - ], - ); - } else { - return Container(); - } + stream: _loadingStream.stream, + builder: (context, snapshot) { + if (snapshot.data ?? false) { + return Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + child: CircularProgressIndicator(), + ), + ], + ); + } else { + return Container(); } + }, ), - Align( alignment: Alignment.bottomCenter, child: Container( width: double.maxFinite, margin: const EdgeInsets.all(16), - child: RaisedButton( - padding: const EdgeInsets.symmetric(vertical: 16), + child: ElevatedButton( child: Text("I AGREE"), - color: context.primaryColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric(vertical: 16), + primary: context.primaryColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), ), onPressed: () { - Analytics().logSelectContent(contentType: 'action', itemId: "terms_of_service"); - context.bloc() - .add(AgreeToTerms()); + Analytics().logSelectContent( + contentType: 'action', itemId: "terms_of_service"); + context.bloc().add(AgreeToTerms()); }, ), ), - ) + ), ], ), );