Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Hunger games: a better loading view + we finally support errors… #4448

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ProductTitleCard extends StatelessWidget {
onRemove: onRemove,
);

if (!(isRemovable && !isSelectable)) {
if (!dense && !(isRemovable && !isSelectable)) {
title = Expanded(child: title);
}

Expand All @@ -46,6 +46,7 @@ class ProductTitleCard extends StatelessWidget {
Expanded(
child: _ProductTitleCardName(
selectable: isSelectable,
dense: dense,
),
),
title,
Expand All @@ -65,8 +66,10 @@ class ProductTitleCard extends StatelessWidget {
class _ProductTitleCardName extends StatelessWidget {
const _ProductTitleCardName({
required this.selectable,
this.dense = false,
});

final bool dense;
final bool selectable;

@override
Expand All @@ -78,7 +81,7 @@ class _ProductTitleCardName extends StatelessWidget {
getProductName(product, appLocalizations),
style: Theme.of(context).textTheme.headlineMedium,
textAlign: TextAlign.start,
maxLines: 3,
maxLines: dense ? 2 : 3,
overflow: TextOverflow.ellipsis,
).selectable(isSelectable: selectable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class SmoothLargeButtonWithIcon extends StatelessWidget {
this.backgroundColor,
this.foregroundColor,
this.textAlign,
this.textStyle,
});

final String text;
Expand All @@ -22,6 +23,7 @@ class SmoothLargeButtonWithIcon extends StatelessWidget {
final Color? backgroundColor;
final Color? foregroundColor;
final TextAlign? textAlign;
final TextStyle? textStyle;

Color _getBackgroundColor(final ThemeData themeData) =>
backgroundColor ?? themeData.colorScheme.secondary;
Expand All @@ -32,6 +34,12 @@ class SmoothLargeButtonWithIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
TextStyle style = textStyle ?? themeData.textTheme.bodyMedium!;

if (style.color == null) {
style = style.copyWith(color: _getForegroundColor(themeData));
}

return SmoothSimpleButton(
minWidth: double.infinity,
padding: padding ?? const EdgeInsets.all(10),
Expand All @@ -51,9 +59,7 @@ class SmoothLargeButtonWithIcon extends StatelessWidget {
text,
maxLines: 2,
textAlign: textAlign,
style: themeData.textTheme.bodyMedium!.copyWith(
color: _getForegroundColor(themeData),
),
style: style,
),
),
const Spacer(),
Expand Down
6 changes: 5 additions & 1 deletion packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2392,5 +2392,9 @@
"nova_group_2": "NOVA Group 2",
"nova_group_3": "NOVA Group 3",
"nova_group_4": "NOVA Group 4",
"nova_group_unknown": "Unknown NOVA Group"
"nova_group_unknown": "Unknown NOVA Group",
"hunger_games_loading_line1": "Please let us a few seconds…",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"hunger_games_loading_line1": "Please let us a few seconds…",
"hunger_games_loading_line1": "Just a few seconds…",

"hunger_games_loading_line2": "We're downloading the questions!",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a We/You wording?

Copy link
Collaborator Author

@g123k g123k Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it's a game, that why I've switched to a more familiar language, but feel free to revert this change

"hunger_games_error_label": "Argh! Something went wrong… and we couldn't load the questions.",
"hunger_games_error_retry_button": "Let's retry!"
}
13 changes: 9 additions & 4 deletions packages/smooth_app/lib/pages/hunger_games/congrats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import 'package:smooth_app/generic_lib/loading_dialog.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_card.dart';
import 'package:smooth_app/pages/user_management/login_page.dart';

typedef AnonymousAnnotationList = Map<String, InsightAnnotation>;

class CongratsWidget extends StatelessWidget {
const CongratsWidget({
required this.continueButtonLabel,
Expand All @@ -22,7 +24,7 @@ class CongratsWidget extends StatelessWidget {

final String? continueButtonLabel;
final VoidCallback? onContinue;
final Map<String, InsightAnnotation> anonymousAnnotationList;
final AnonymousAnnotationList anonymousAnnotationList;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -69,9 +71,12 @@ class CongratsWidget extends StatelessWidget {
),
Align(
alignment: AlignmentDirectional.bottomEnd,
child: SmoothSimpleButton(
child: Text(appLocalizations.close),
onPressed: () => Navigator.maybePop<Widget>(context),
child: Padding(
padding: const EdgeInsets.only(bottom: MEDIUM_SPACE),
child: SmoothSimpleButton(
child: Text(appLocalizations.close),
onPressed: () => Navigator.maybePop<Widget>(context),
),
),
),
],
Expand Down
8 changes: 6 additions & 2 deletions packages/smooth_app/lib/pages/hunger_games/question_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ class QuestionCard extends StatelessWidget {
: QuestionImageThumbnail(question),
),
Padding(
padding:
const EdgeInsets.symmetric(horizontal: SMALL_SPACE),
padding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
end: SMALL_SPACE,
top: SMALL_SPACE,
bottom: VERY_SMALL_SPACE,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expand Down
Loading