Skip to content
Open
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
54 changes: 54 additions & 0 deletions game/assets/icons/bear_popup.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions game/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
PODS:
- app_settings (5.1.1):
- Flutter
- AppAuth (1.7.6):
- AppAuth/Core (= 1.7.6)
- AppAuth/ExternalUserAgent (= 1.7.6)
Expand Down Expand Up @@ -185,6 +187,7 @@ PODS:
- Flutter

DEPENDENCIES:
- app_settings (from `.symlinks/plugins/app_settings/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Firebase
- Firebase/Analytics
Expand Down Expand Up @@ -229,6 +232,8 @@ SPEC REPOS:
- PromisesObjC

EXTERNAL SOURCES:
app_settings:
:path: ".symlinks/plugins/app_settings/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
firebase_core:
Expand Down Expand Up @@ -269,6 +274,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
app_settings: 3507c575c2b18a462c99948f61d5de21d4420999
AppAuth: d4f13a8fe0baf391b2108511793e4b479691fb73
device_info_plus: 71ffc6ab7634ade6267c7a93088ed7e4f74e5896
Firebase: d99ac19b909cd2c548339c2241ecd0d1599ab02e
Expand Down
15 changes: 15 additions & 0 deletions game/lib/navigation_page/bottom_navbar.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:game/api/game_api.dart';
import 'package:game/global_leaderboard/global_leaderboard_widget.dart';
Expand All @@ -12,6 +13,7 @@ import 'package:game/model/tracker_model.dart';
import 'package:game/model/challenge_model.dart';
import 'package:game/widgets/bear_mascot_message.dart';
import 'package:game/utils/utility_functions.dart';
import 'package:game/widgets/envelope_popup.dart';
import 'package:showcaseview/showcaseview.dart';
import 'search_filter_home.dart';

Expand Down Expand Up @@ -80,6 +82,19 @@ class _BottomNavBarState extends State<BottomNavBar> {
GlobalLeaderboardWidget(),
ProfilePage(),
];

// TODO: testing purposes only, remove later
if (kDebugMode) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (!mounted) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great Selina. Last thing would be to determine the frequency we want to show this pop-up, maybe if they don't want notifications we shouldn't bother them every single time they open the app. Additionally, when notifications ARE turned on, the popup still appears. There should be a way to see if they turned them on already.

await showEnvelopePopup(
context,
titleText: 'FREE FOOD!',
envelopeText: 'BOBA!',
buttonLabel: 'Turn On Notifications',
);
});
}
}

@override
Expand Down
244 changes: 244 additions & 0 deletions game/lib/widgets/envelope_popup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
import 'package:app_settings/app_settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

/**
* `EnvelopePopup` Widget - Bear envelope popup with configurable text.
*
* @remarks
* - Header line 1 is fixed: "DON'T MISS OUT ON"
* - If `buttonLabel` is "Turn On Notifications" and `onButtonPressed` is null,
* the CTA opens the device app settings.
*
* @param titleText - Header line 2
* @param envelopeText - Text shown inside the envelope
* @param buttonLabel - CTA label
* @param onButtonPressed - Optional CTA handler
* @param onClose - Optional cancel handler
*/
class EnvelopePopup extends StatelessWidget {
const EnvelopePopup({
super.key,
required this.titleText,
required this.envelopeText,
required this.buttonLabel,
this.onButtonPressed,
this.onClose,
});

final String titleText;
final String envelopeText;
final String buttonLabel;
final VoidCallback? onButtonPressed;
final VoidCallback? onClose;

static const String _settingsButtonLabel = 'Turn On Notifications';
static const String _headerLine1 = "DON'T MISS OUT ON";
static const double _illustrationWidth = 180;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

return Dialog(
backgroundColor: Colors.white,
insetPadding: const EdgeInsets.symmetric(horizontal: 36, vertical: 18),
alignment: const Alignment(0, -0.6),
elevation: 0,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 350),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.fromLTRB(12, 12, 12, 12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.centerRight,
child: InkResponse(
onTap: () {
onClose?.call();
Navigator.of(context).maybePop();
},
radius: 20,
child: SvgPicture.asset(
'assets/icons/cancel.svg',
width: 32,
height: 32,
colorFilter: const ColorFilter.mode(
Colors.black38,
BlendMode.srcIn,
),
),
),
),
const SizedBox(height: 4),
_PopupHeader(
line1: _headerLine1,
line2: titleText,
),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: _illustrationWidth,
),
child: _BearEnvelopeGraphic(envelopeText: envelopeText),
),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () async {
if (onButtonPressed != null) {
onButtonPressed!.call();
return;
}

if (buttonLabel.trim() == _settingsButtonLabel) {
await AppSettings.openAppSettings();
return;
}

Navigator.of(context).maybePop();
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: const Color(0xFF7A5A73),
foregroundColor: Colors.white,
elevation: 0,
shadowColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
textStyle: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700,
),
),
child: Text(buttonLabel),
),
),
],
),
),
),
),
);
}
}

class _BearEnvelopeGraphic extends StatelessWidget {
const _BearEnvelopeGraphic({required this.envelopeText});

final String envelopeText;
static const double _envelopeTextRotationRad = -(2 * 3.14 / 180);

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth;
final height = width * (296 / 177);

return SizedBox(
width: width,
height: height,
child: Stack(
children: [
Positioned.fill(
child: SvgPicture.asset(
'assets/icons/bear_popup.svg',
fit: BoxFit.contain,
),
),
Positioned.fill(
child: Align(
alignment: const Alignment(0, -0.58),
child: FractionallySizedBox(
widthFactor: 0.62,
child: FittedBox(
fit: BoxFit.scaleDown,
child: Transform.rotate(
angle: _envelopeTextRotationRad,
child: Text(
envelopeText.toUpperCase(),
textAlign: TextAlign.center,
style: theme.textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.w900,
color: const Color(0xFFE94C4C),
letterSpacing: 1.0,
height: 1.0,
),
),
),
),
),
),
),
],
),
);
},
);
}
}

class _PopupHeader extends StatelessWidget {
const _PopupHeader({required this.line1, required this.line2});

final String line1;
final String line2;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);

return Column(
children: [
Text(
line1,
textAlign: TextAlign.center,
style: theme.textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700,
fontSize: 24,
fontFamily: 'Poppins',
color: const Color(0xFF1E1E1E),
),
),
Text(
line2,
textAlign: TextAlign.center,
style: theme.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.w700,
fontSize: 36,
fontFamily: 'Poppins',
height: 1.1,
letterSpacing: 0.4,
color: const Color(0xFF1E1E1E),
),
),
],
);
}
}

// Shows an `EnvelopePopup` dialog.
Future<void> showEnvelopePopup(
BuildContext context, {
required String titleText,
required String envelopeText,
required String buttonLabel,
VoidCallback? onButtonPressed,
}) async {
await showDialog<void>(
context: context,
barrierColor: Colors.black.withOpacity(0.12),
barrierDismissible: true,
builder: (context) => EnvelopePopup(
titleText: titleText,
envelopeText: envelopeText,
buttonLabel: buttonLabel,
onButtonPressed: onButtonPressed,
),
);
}
12 changes: 10 additions & 2 deletions game/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.59"
app_settings:
dependency: "direct main"
description:
name: app_settings
sha256: "09bc7fe0313a507087bec1a3baf555f0576e816a760cbb31813a88890a09d9e5"
url: "https://pub.dev"
source: hosted
version: "5.1.1"
archive:
dependency: transitive
description:
Expand Down Expand Up @@ -1499,5 +1507,5 @@ packages:
source: hosted
version: "3.1.3"
sdks:
dart: ">=3.8.0-0 <4.0.0"
flutter: ">=3.29.0"
dart: ">=3.9.0 <4.0.0"
flutter: ">=3.35.0"
1 change: 1 addition & 0 deletions game/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
sdk: flutter
flutter_localizations:
sdk: flutter
app_settings: 5.1.1
# Firebase
firebase_core: ^3.8.1
firebase_messaging: ^15.1.6
Expand Down
Loading