Skip to content

Commit

Permalink
Show sheet for qr code (#99)
Browse files Browse the repository at this point in the history
* show sheet for qr code

* fix lint

* show description instead of id

* release build fails

* add padding
  • Loading branch information
cp-sidhdhi-p authored Sep 23, 2024
1 parent 3f054cc commit 8f6cb3f
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 137 deletions.
14 changes: 13 additions & 1 deletion khelo/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.9.23'
ext.kotlin_version = '2.0.20'
repositories {
google()
mavenCentral()
Expand All @@ -19,6 +19,18 @@ allprojects {
}

rootProject.buildDir = '../build'

subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin("com.android.application") ||
project.plugins.hasPlugin("com.android.library")) {
project.android {
compileSdkVersion 34
buildToolsVersion "34.0.0"
}
}
}
}
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
Expand Down
1 change: 1 addition & 0 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@
"profile_setting_app_version_text": "App Version: {version}",
"profile_setting_scan_to_play_text": "Scan to play!",
"profile_setting_scan_to_play_description": "This QR code allows you to easily add the player to the team.",
"profile_setting_use_scanner_description": "Use your phone camera or a QR code app to scan the code above and easily add the player to the team.",

"@_NOTIFICATION": {
},
Expand Down
28 changes: 14 additions & 14 deletions khelo/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1151,11 +1151,11 @@ PODS:
- BoringSSL-GRPC/Implementation (0.0.36):
- BoringSSL-GRPC/Interface (= 0.0.36)
- BoringSSL-GRPC/Interface (0.0.36)
- cloud_firestore (5.3.0):
- cloud_firestore (5.4.2):
- Firebase/Firestore (= 11.0.0)
- firebase_core
- Flutter
- cloud_functions (5.1.1):
- cloud_functions (5.1.2):
- Firebase/Functions (= 11.0.0)
- firebase_core
- Flutter
Expand Down Expand Up @@ -1183,22 +1183,22 @@ PODS:
- Firebase/Storage (11.0.0):
- Firebase/CoreOnly
- FirebaseStorage (~> 11.0.0)
- firebase_auth (5.2.0):
- firebase_auth (5.3.0):
- Firebase/Auth (= 11.0.0)
- firebase_core
- Flutter
- firebase_core (3.4.1):
- firebase_core (3.5.0):
- Firebase/CoreOnly (= 11.0.0)
- Flutter
- firebase_crashlytics (4.1.0):
- firebase_crashlytics (4.1.2):
- Firebase/Crashlytics (= 11.0.0)
- firebase_core
- Flutter
- firebase_messaging (15.1.0):
- firebase_messaging (15.1.2):
- Firebase/Messaging (= 11.0.0)
- firebase_core
- Flutter
- firebase_storage (12.2.0):
- firebase_storage (12.3.1):
- Firebase/Storage (= 11.0.0)
- firebase_core
- Flutter
Expand Down Expand Up @@ -1555,16 +1555,16 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
abseil: d121da9ef7e2ff4cab7666e76c5a3e0915ae08c3
BoringSSL-GRPC: ca6a8e5d04812fce8ffd6437810c2d46f925eaeb
cloud_firestore: 15d5767445fbd525df58295240753e87393c854f
cloud_functions: 8503b9219ebace7211e7289a59e2b9b0c53461c2
cloud_firestore: efded0403c9e674954e2788d93bc2772a5089557
cloud_functions: 167c9f94438de5c039036675878d9da3889f5d8f
contacts_service: 849e1f84281804c8bfbec1b4c3eedcb23c5d3eca
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
Firebase: 9f574c08c2396885b5e7e100ed4293d956218af9
firebase_auth: 16ac5db3d064db837ecd845080d7e18e4be7c66d
firebase_core: ba84e940cf5cbbc601095f86556560937419195c
firebase_crashlytics: e4f04180f443d5a8b56fbc0685bdbd7d90dd26f0
firebase_messaging: 15d8b557010f3bb7b98d0302e1c7c8fbcd244425
firebase_storage: 3b166e39a19e95b6a2d1c33b4ebff41e12a7615b
firebase_auth: f27287630c4d9e2c3c63e64d9240822ad6b07e5b
firebase_core: 2ec6b789859c7c24766344ec71fdf78639402d56
firebase_crashlytics: 60630a0f91ee432275fa1660fd8593079761448a
firebase_messaging: a18e1e02b2e8e69097c8173e0c851be223b21c50
firebase_storage: 9e484b4e90a239066e535a2ee2b6d662b140372b
FirebaseAppCheckInterop: e59b52f2c0e188e6ba77b9e3f6acead2117f2abf
FirebaseAuth: d5cf28be74d7e82257f6a3f717509eff70d3cf4a
FirebaseAuthInterop: 49e8faefaf254ce578e278a84a8fe0aebe23b546
Expand Down
20 changes: 6 additions & 14 deletions khelo/lib/ui/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import 'flow/team/user_detail/user_detail_screen.dart';
class AppRoute {
static const pathPhoneNumberVerification = '/phone-number-verification';
static const pathEditProfile = '/edit-profile';
static const pathContactSupport = "/contact-support";
static const pathAddTeamMember = '/add-team-member';
static const pathAddTeam = '/add-team';
static const pathPowerPlay = '/power-play';
Expand Down Expand Up @@ -130,6 +129,11 @@ class AppRoute {
static AppRoute get phoneLogin =>
AppRoute("/phone-login", builder: (_) => const SignInWithPhoneScreen());

static AppRoute get contactSupport => AppRoute(
"/contact-support",
builder: (_) => const ContactSupportScreen(),
);

static AppRoute scoreBoard({required String matchId}) => AppRoute(
pathScoreBoard,
builder: (_) => ScoreBoardScreen(
Expand Down Expand Up @@ -240,11 +244,6 @@ class AppRoute {
pathEditProfile,
builder: (_) => EditProfileScreen(isToCreateAccount: isToCreateAccount));

static AppRoute contactSupport() => AppRoute(
pathContactSupport,
builder: (_) => const ContactSupportScreen(),
);

static AppRoute teamDetail({required String teamId}) =>
AppRoute(pathTeamDetail,
builder: (_) => TeamDetailScreen(teamId: teamId));
Expand Down Expand Up @@ -288,14 +287,7 @@ class AppRoute {
: state.widget(context);
},
),
GoRoute(
path: pathContactSupport,
builder: (context, state) {
return state.extra == null
? const ContactSupportScreen()
: state.widget(context);
},
),
contactSupport.goRoute(),
phoneLogin.goRoute(),
GoRoute(
path: pathScoreBoard,
Expand Down
77 changes: 77 additions & 0 deletions khelo/lib/ui/flow/profile/components/qr_code_sheet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:style/button/action_button.dart';
import 'package:style/extensions/context_extensions.dart';
import 'package:style/text/app_text_style.dart';

class QrCodeSheet extends StatelessWidget {
final String userId;

static Future<T?> show<T>(
BuildContext context, {
required String userId,
}) {
HapticFeedback.mediumImpact();
return showModalBottomSheet(
context: context,
showDragHandle: false,
enableDrag: false,
isScrollControlled: true,
useRootNavigator: true,
backgroundColor: context.colorScheme.surface,
builder: (context) => QrCodeSheet(userId: userId),
);
}

const QrCodeSheet({super.key, required this.userId});

@override
Widget build(BuildContext context) {
return Container(
constraints:
BoxConstraints(maxHeight: context.mediaQuerySize.height * 0.8),
decoration: BoxDecoration(
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
color: context.colorScheme.surface,
),
child: SingleChildScrollView(
padding: context.mediaQueryPadding +
const EdgeInsets.symmetric(vertical: 24, horizontal: 16),
child: Column(
children: [
Align(
alignment: Alignment.centerRight,
child: actionButton(context,
icon: Icon(
Icons.close,
color: context.colorScheme.textSecondary,
),
onPressed: context.pop)),
const SizedBox(height: 24),
QrImageView(
data: userId,
version: QrVersions.auto,
size: 240,
dataModuleStyle: QrDataModuleStyle(
dataModuleShape: QrDataModuleShape.square,
color: context.colorScheme.textPrimary),
eyeStyle: QrEyeStyle(
eyeShape: QrEyeShape.square,
color: context.colorScheme.textPrimary),
),
const SizedBox(height: 24),
Text(
context.l10n.profile_setting_use_scanner_description,
textAlign: TextAlign.center,
style: AppTextStyle.subtitle1
.copyWith(color: context.colorScheme.textSecondary),
),
],
),
),
);
}
}
74 changes: 39 additions & 35 deletions khelo/lib/ui/flow/profile/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:khelo/components/image_avatar.dart';
import 'package:khelo/domain/extensions/context_extensions.dart';
import 'package:khelo/ui/app_route.dart';
import 'package:khelo/ui/flow/profile/components/complete_profile_progress.dart';
import 'package:khelo/ui/flow/profile/components/qr_code_sheet.dart';
import 'package:khelo/ui/flow/profile/profile_view_model.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:permission_handler/permission_handler.dart';
Expand Down Expand Up @@ -175,7 +176,7 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen>
context,
icon: Assets.images.icContactSupport,
title: context.l10n.contact_support_title,
onTap: () => AppRoute.contactSupport().push(context),
onTap: () => AppRoute.contactSupport.push(context),
),
_settingItem(
context,
Expand Down Expand Up @@ -249,41 +250,44 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen>
BuildContext context,
String userId,
) {
return Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: context.colorScheme.outline),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.profile_setting_scan_to_play_text,
style: AppTextStyle.header4
.copyWith(color: context.colorScheme.textPrimary),
),
const SizedBox(height: 8),
Text(
context.l10n.profile_setting_scan_to_play_description,
style: AppTextStyle.subtitle3
.copyWith(color: context.colorScheme.textSecondary),
),
const SizedBox(height: 24),
Center(
child: QrImageView(
data: userId,
version: QrVersions.auto,
size: 120.0,
dataModuleStyle: QrDataModuleStyle(
dataModuleShape: QrDataModuleShape.square,
color: context.colorScheme.textPrimary),
eyeStyle: QrEyeStyle(
eyeShape: QrEyeShape.square,
color: context.colorScheme.textPrimary),
return OnTapScale(
onTap: () => QrCodeSheet.show(context, userId: userId),
child: Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: context.colorScheme.outline),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.profile_setting_scan_to_play_text,
style: AppTextStyle.header4
.copyWith(color: context.colorScheme.textPrimary),
),
),
],
const SizedBox(height: 8),
Text(
context.l10n.profile_setting_scan_to_play_description,
style: AppTextStyle.subtitle3
.copyWith(color: context.colorScheme.textSecondary),
),
const SizedBox(height: 24),
Center(
child: QrImageView(
data: userId,
version: QrVersions.auto,
size: 120.0,
dataModuleStyle: QrDataModuleStyle(
dataModuleShape: QrDataModuleShape.square,
color: context.colorScheme.textPrimary),
eyeStyle: QrEyeStyle(
eyeShape: QrEyeShape.square,
color: context.colorScheme.textPrimary),
),
),
],
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class UserDetailInfoContent extends ConsumerWidget {
_infoRowView(
context,
context.l10n.user_detail_joining_date_title,
(state.user?.created_at)
?.format(context, DateFormatType.shortDate)),
state.user?.created_at?.format(context, DateFormatType.shortDate)),
_infoRowView(context, context.l10n.common_gender_title,
state.user?.gender?.getString(context)),
_infoRowView(
Expand Down
Loading

0 comments on commit 8f6cb3f

Please sign in to comment.