From cbcfd643dc77e037e34e8590359b019ebc7be87b Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 09:48:58 +0530 Subject: [PATCH 01/10] add user via name and contact --- khelo/assets/locales/app_en.arb | 2 + khelo/ios/Podfile | 6 +- khelo/ios/Podfile.lock | 2 +- khelo/ios/Runner.xcodeproj/project.pbxproj | 26 ++-- .../confirm_number_sheet.dart | 114 +++++++++++------- .../confirm_number_view_model.dart | 20 +-- .../confirm_number_view_model.freezed.dart | 77 ++++++++---- .../contact_selection_screen.dart | 39 ++++-- khelo/macos/Runner.xcodeproj/project.pbxproj | 4 +- 9 files changed, 188 insertions(+), 102 deletions(-) diff --git a/khelo/assets/locales/app_en.arb b/khelo/assets/locales/app_en.arb index 156a4415..d2711fe1 100644 --- a/khelo/assets/locales/app_en.arb +++ b/khelo/assets/locales/app_en.arb @@ -184,6 +184,8 @@ "confirm_number_confirm_phone_title": "Confirm phone number", "confirm_number_confirm_title": "Confirm", + "confirm_number_name_title": "Name", + "confirm_number_add_user_manually_title": "Add user manually", "team_list_add_members_title": "Add Members", "team_list_all_teams_title": "All teams", diff --git a/khelo/ios/Podfile b/khelo/ios/Podfile index 3cefbba5..3beeeed5 100644 --- a/khelo/ios/Podfile +++ b/khelo/ios/Podfile @@ -50,8 +50,12 @@ post_install do |installer| ## dart: PermissionGroup.notification 'PERMISSION_NOTIFICATIONS=1', + ## dart: PermissionGroup.camera 'PERMISSION_CAMERA=1', + + ## dart: PermissionGroup.contacts + 'PERMISSION_CONTACTS=1', ] end @@ -64,8 +68,6 @@ post_install do |installer| ## dart: PermissionGroup.notification 'PERMISSION_NOTIFICATIONS=1', - ## dart: PermissionGroup.camera - 'PERMISSION_CAMERA=1', ] end # End of the permission_handler configuration diff --git a/khelo/ios/Podfile.lock b/khelo/ios/Podfile.lock index 8eae3191..5f6ace19 100644 --- a/khelo/ios/Podfile.lock +++ b/khelo/ios/Podfile.lock @@ -1617,6 +1617,6 @@ SPEC CHECKSUMS: TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe -PODFILE CHECKSUM: d498f76935296deef3b8cdc54d2f1c29ab5e4e95 +PODFILE CHECKSUM: 263bbdc4af357de40d8d908cfc1d29ff7d1f184b COCOAPODS: 1.15.2 diff --git a/khelo/ios/Runner.xcodeproj/project.pbxproj b/khelo/ios/Runner.xcodeproj/project.pbxproj index 006883e3..682ace3b 100644 --- a/khelo/ios/Runner.xcodeproj/project.pbxproj +++ b/khelo/ios/Runner.xcodeproj/project.pbxproj @@ -206,7 +206,7 @@ 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 9C8DD79CF293961A8F4177C2 /* [CP] Embed Pods Frameworks */, 9EE7146958D62CE1CD764FEE /* [CP] Copy Pods Resources */, - 8F0726FF57A30C2BEB3C5278 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, + 3526C9B46C8E72D356D2469A /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, ); buildRules = ( ); @@ -301,39 +301,39 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + 3526C9B46C8E72D356D2469A /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); + inputFileListPaths = ( + ); inputPaths = ( - "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); - name = "Thin Binary"; + name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\""; + outputFileListPaths = ( + ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; + shellScript = "\n#!/bin/bash\nPATH=${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=$PODS_ROOT/FirebaseCrashlytics/upload-symbols --platform=ios --apple-project-path=${SRCROOT} --env-platform-name=${PLATFORM_NAME} --env-configuration=${CONFIGURATION} --env-project-dir=${PROJECT_DIR} --env-built-products-dir=${BUILT_PRODUCTS_DIR} --env-dwarf-dsym-folder-path=${DWARF_DSYM_FOLDER_PATH} --env-dwarf-dsym-file-name=${DWARF_DSYM_FILE_NAME} --env-infoplist-path=${INFOPLIST_PATH} --default-config=default\n"; }; - 8F0726FF57A30C2BEB3C5278 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); - name = "FlutterFire: \"flutterfire upload-crashlytics-symbols\""; - outputFileListPaths = ( - ); + name = "Thin Binary"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\n#!/bin/bash\nPATH=${PATH}:$FLUTTER_ROOT/bin:$HOME/.pub-cache/bin\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=$PODS_ROOT/FirebaseCrashlytics/upload-symbols --platform=ios --apple-project-path=${SRCROOT} --env-platform-name=${PLATFORM_NAME} --env-configuration=${CONFIGURATION} --env-project-dir=${PROJECT_DIR} --env-built-products-dir=${BUILT_PRODUCTS_DIR} --env-dwarf-dsym-folder-path=${DWARF_DSYM_FOLDER_PATH} --env-dwarf-dsym-file-name=${DWARF_DSYM_FILE_NAME} --env-infoplist-path=${INFOPLIST_PATH} --default-config=default\n"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; diff --git a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart index 520316fc..1d981d1b 100644 --- a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart +++ b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart @@ -16,11 +16,13 @@ import 'confirm_number_view_model.dart'; class ConfirmNumberSheet extends ConsumerStatefulWidget { final CountryCode? code; final String? defaultNumber; + final bool isForCreateUser; static Future show( BuildContext context, { CountryCode? code, String? defaultNumber, + bool isForCreateUser = false, }) { HapticFeedback.mediumImpact(); return showModalBottomSheet( @@ -37,6 +39,7 @@ class ConfirmNumberSheet extends ConsumerStatefulWidget { child: ConfirmNumberSheet( code: code, defaultNumber: defaultNumber, + isForCreateUser: isForCreateUser, ), ); }, @@ -47,6 +50,7 @@ class ConfirmNumberSheet extends ConsumerStatefulWidget { super.key, this.code, this.defaultNumber, + this.isForCreateUser = false, }); @override @@ -59,7 +63,8 @@ class _ConfirmNumberSheetState extends ConsumerState { @override void initState() { notifier = ref.read(confirmNumberStateProvider.notifier); - runPostFrame(() => notifier.setDate(widget.code, widget.defaultNumber)); + runPostFrame(() => notifier.setDate( + widget.code, widget.defaultNumber, widget.isForCreateUser)); super.initState(); } @@ -78,11 +83,39 @@ class _ConfirmNumberSheetState extends ConsumerState { mainAxisSize: MainAxisSize.min, children: [ Text( - context.l10n.confirm_number_confirm_phone_title, + state.isForCreateUser + ? context.l10n.confirm_number_add_user_manually_title + : context.l10n.confirm_number_confirm_phone_title, style: AppTextStyle.header3 .copyWith(color: context.colorScheme.textPrimary), ), + const SizedBox(height: 24), + if (state.isForCreateUser) ...[ + AppTextField( + controller: state.nameController, + autoFocus: true, + style: AppTextStyle.subtitle3.copyWith( + color: context.colorScheme.textPrimary, + ), + hintStyle: AppTextStyle.subtitle3.copyWith( + color: context.colorScheme.textDisabled, + ), + hintText: context.l10n.confirm_number_name_title, + backgroundColor: context.colorScheme.containerLowOnSurface, + borderRadius: BorderRadius.circular(30), + borderType: AppTextFieldBorderType.outline, + borderColor: BorderColor( + focusColor: Colors.transparent, + unFocusColor: Colors.transparent), + onChanged: (_) => notifier.onTextChange(), + contentPadding: const EdgeInsets.symmetric(horizontal: 16), + onTapOutside: (event) => + FocusManager.instance.primaryFocus?.unfocus(), + ), + const SizedBox(height: 24), + ], _phoneInputField(context, state), + const SizedBox(height: 40), PrimaryButton( context.l10n.confirm_number_confirm_title, enabled: state.isButtonEnable, @@ -99,47 +132,43 @@ class _ConfirmNumberSheetState extends ConsumerState { ConfirmNumberViewState state, ) { return MediaQuery.withNoTextScaling( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 40), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CountryCodeView( - countryCode: state.code, - onCodeChange: notifier.onCodeChange, - ), - const SizedBox(width: 8), - Expanded( - child: AppTextField( - controller: state.phoneController, - autoFocus: true, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - style: AppTextStyle.header2.copyWith( - color: context.colorScheme.textSecondary, - ), - hintStyle: AppTextStyle.header2.copyWith( - color: context.colorScheme.outline, - ), - hintText: context.l10n.sign_in_phone_number_placeholder, - backgroundColor: context.colorScheme.containerLowOnSurface, - borderRadius: BorderRadius.circular(40), - borderType: AppTextFieldBorderType.outline, - borderColor: BorderColor( - focusColor: Colors.transparent, - unFocusColor: Colors.transparent), - prefixIcon: _inputFieldPrefix(context, state), - prefixIconConstraints: const BoxConstraints.tightFor(), - onChanged: (_) => notifier.onTextChange(), - onSubmitted: (_) => notifier.onConfirmTap(), - onTapOutside: (event) => - FocusManager.instance.primaryFocus?.unfocus(), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CountryCodeView( + countryCode: state.code, + onCodeChange: notifier.onCodeChange, + ), + const SizedBox(width: 8), + Expanded( + child: AppTextField( + controller: state.phoneController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + style: AppTextStyle.header2.copyWith( + color: context.colorScheme.textSecondary, ), + hintStyle: AppTextStyle.header2.copyWith( + color: context.colorScheme.outline, + ), + hintText: context.l10n.sign_in_phone_number_placeholder, + backgroundColor: context.colorScheme.containerLowOnSurface, + borderRadius: BorderRadius.circular(40), + borderType: AppTextFieldBorderType.outline, + borderColor: BorderColor( + focusColor: Colors.transparent, + unFocusColor: Colors.transparent), + prefixIcon: _inputFieldPrefix(context, state), + prefixIconConstraints: const BoxConstraints.tightFor(), + onChanged: (_) => notifier.onTextChange(), + onSubmitted: (_) => notifier.onConfirmTap(), + onTapOutside: (event) => + FocusManager.instance.primaryFocus?.unfocus(), ), - ], - ), + ), + ], ), ); } @@ -173,8 +202,9 @@ class _ConfirmNumberSheetState extends ConsumerState { ref.listen(confirmNumberStateProvider.select((value) => value.isPop), (previous, next) { if (next == true && context.mounted) { + String name = state.nameController.text; String number = state.phoneController.text; - context.pop((state.code, number)); + context.pop((name, state.code, number)); } }); } diff --git a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart index 04e992d6..d30c26b4 100644 --- a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart +++ b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart @@ -14,17 +14,21 @@ class ConfirmNumberViewNotifier extends StateNotifier { ConfirmNumberViewNotifier() : super(ConfirmNumberViewState( phoneController: TextEditingController(), + nameController: TextEditingController(), code: CountryCode.getCountryCodeByAlpha2( countryAlpha2Code: WidgetsBinding.instance.platformDispatcher.locale.countryCode, ), )); - void setDate(CountryCode? code, String? defaultNumber) { + void setDate( + CountryCode? code, + String? defaultNumber, + bool isForCreateUser, + ) { state.phoneController.text = defaultNumber ?? ''; - if (code != null) { - state = state.copyWith(code: code); - } + state = state.copyWith( + isForCreateUser: isForCreateUser, code: code ?? state.code); onTextChange(); } @@ -33,8 +37,9 @@ class ConfirmNumberViewNotifier extends StateNotifier { } void onTextChange() { - state = state.copyWith( - isButtonEnable: state.phoneController.text.length > 3); + final isButtonEnabled = state.phoneController.text.length > 3 && + (state.isForCreateUser ? state.nameController.text.length > 3 : true); + state = state.copyWith(isButtonEnable: isButtonEnabled); } void onConfirmTap() { @@ -45,10 +50,11 @@ class ConfirmNumberViewNotifier extends StateNotifier { @freezed class ConfirmNumberViewState with _$ConfirmNumberViewState { const factory ConfirmNumberViewState({ - Object? error, required TextEditingController phoneController, + required TextEditingController nameController, required CountryCode code, @Default(false) bool isButtonEnable, + @Default(false) bool isForCreateUser, @Default(false) bool isPop, }) = _ConfirmNumberViewState; } diff --git a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.freezed.dart b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.freezed.dart index e82d3fd9..1d169e39 100644 --- a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.freezed.dart +++ b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.freezed.dart @@ -16,11 +16,13 @@ final _privateConstructorUsedError = UnsupportedError( /// @nodoc mixin _$ConfirmNumberViewState { - Object? get error => throw _privateConstructorUsedError; TextEditingController get phoneController => throw _privateConstructorUsedError; + TextEditingController get nameController => + throw _privateConstructorUsedError; CountryCode get code => throw _privateConstructorUsedError; bool get isButtonEnable => throw _privateConstructorUsedError; + bool get isForCreateUser => throw _privateConstructorUsedError; bool get isPop => throw _privateConstructorUsedError; /// Create a copy of ConfirmNumberViewState @@ -37,10 +39,11 @@ abstract class $ConfirmNumberViewStateCopyWith<$Res> { _$ConfirmNumberViewStateCopyWithImpl<$Res, ConfirmNumberViewState>; @useResult $Res call( - {Object? error, - TextEditingController phoneController, + {TextEditingController phoneController, + TextEditingController nameController, CountryCode code, bool isButtonEnable, + bool isForCreateUser, bool isPop}); } @@ -60,18 +63,22 @@ class _$ConfirmNumberViewStateCopyWithImpl<$Res, @pragma('vm:prefer-inline') @override $Res call({ - Object? error = freezed, Object? phoneController = null, + Object? nameController = null, Object? code = null, Object? isButtonEnable = null, + Object? isForCreateUser = null, Object? isPop = null, }) { return _then(_value.copyWith( - error: freezed == error ? _value.error : error, phoneController: null == phoneController ? _value.phoneController : phoneController // ignore: cast_nullable_to_non_nullable as TextEditingController, + nameController: null == nameController + ? _value.nameController + : nameController // ignore: cast_nullable_to_non_nullable + as TextEditingController, code: null == code ? _value.code : code // ignore: cast_nullable_to_non_nullable @@ -80,6 +87,10 @@ class _$ConfirmNumberViewStateCopyWithImpl<$Res, ? _value.isButtonEnable : isButtonEnable // ignore: cast_nullable_to_non_nullable as bool, + isForCreateUser: null == isForCreateUser + ? _value.isForCreateUser + : isForCreateUser // ignore: cast_nullable_to_non_nullable + as bool, isPop: null == isPop ? _value.isPop : isPop // ignore: cast_nullable_to_non_nullable @@ -98,10 +109,11 @@ abstract class _$$ConfirmNumberViewStateImplCopyWith<$Res> @override @useResult $Res call( - {Object? error, - TextEditingController phoneController, + {TextEditingController phoneController, + TextEditingController nameController, CountryCode code, bool isButtonEnable, + bool isForCreateUser, bool isPop}); } @@ -120,18 +132,22 @@ class __$$ConfirmNumberViewStateImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? error = freezed, Object? phoneController = null, + Object? nameController = null, Object? code = null, Object? isButtonEnable = null, + Object? isForCreateUser = null, Object? isPop = null, }) { return _then(_$ConfirmNumberViewStateImpl( - error: freezed == error ? _value.error : error, phoneController: null == phoneController ? _value.phoneController : phoneController // ignore: cast_nullable_to_non_nullable as TextEditingController, + nameController: null == nameController + ? _value.nameController + : nameController // ignore: cast_nullable_to_non_nullable + as TextEditingController, code: null == code ? _value.code : code // ignore: cast_nullable_to_non_nullable @@ -140,6 +156,10 @@ class __$$ConfirmNumberViewStateImplCopyWithImpl<$Res> ? _value.isButtonEnable : isButtonEnable // ignore: cast_nullable_to_non_nullable as bool, + isForCreateUser: null == isForCreateUser + ? _value.isForCreateUser + : isForCreateUser // ignore: cast_nullable_to_non_nullable + as bool, isPop: null == isPop ? _value.isPop : isPop // ignore: cast_nullable_to_non_nullable @@ -152,28 +172,32 @@ class __$$ConfirmNumberViewStateImplCopyWithImpl<$Res> class _$ConfirmNumberViewStateImpl implements _ConfirmNumberViewState { const _$ConfirmNumberViewStateImpl( - {this.error, - required this.phoneController, + {required this.phoneController, + required this.nameController, required this.code, this.isButtonEnable = false, + this.isForCreateUser = false, this.isPop = false}); - @override - final Object? error; @override final TextEditingController phoneController; @override + final TextEditingController nameController; + @override final CountryCode code; @override @JsonKey() final bool isButtonEnable; @override @JsonKey() + final bool isForCreateUser; + @override + @JsonKey() final bool isPop; @override String toString() { - return 'ConfirmNumberViewState(error: $error, phoneController: $phoneController, code: $code, isButtonEnable: $isButtonEnable, isPop: $isPop)'; + return 'ConfirmNumberViewState(phoneController: $phoneController, nameController: $nameController, code: $code, isButtonEnable: $isButtonEnable, isForCreateUser: $isForCreateUser, isPop: $isPop)'; } @override @@ -181,23 +205,21 @@ class _$ConfirmNumberViewStateImpl implements _ConfirmNumberViewState { return identical(this, other) || (other.runtimeType == runtimeType && other is _$ConfirmNumberViewStateImpl && - const DeepCollectionEquality().equals(other.error, error) && (identical(other.phoneController, phoneController) || other.phoneController == phoneController) && + (identical(other.nameController, nameController) || + other.nameController == nameController) && (identical(other.code, code) || other.code == code) && (identical(other.isButtonEnable, isButtonEnable) || other.isButtonEnable == isButtonEnable) && + (identical(other.isForCreateUser, isForCreateUser) || + other.isForCreateUser == isForCreateUser) && (identical(other.isPop, isPop) || other.isPop == isPop)); } @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(error), - phoneController, - code, - isButtonEnable, - isPop); + int get hashCode => Object.hash(runtimeType, phoneController, nameController, + code, isButtonEnable, isForCreateUser, isPop); /// Create a copy of ConfirmNumberViewState /// with the given fields replaced by the non-null parameter values. @@ -211,21 +233,24 @@ class _$ConfirmNumberViewStateImpl implements _ConfirmNumberViewState { abstract class _ConfirmNumberViewState implements ConfirmNumberViewState { const factory _ConfirmNumberViewState( - {final Object? error, - required final TextEditingController phoneController, + {required final TextEditingController phoneController, + required final TextEditingController nameController, required final CountryCode code, final bool isButtonEnable, + final bool isForCreateUser, final bool isPop}) = _$ConfirmNumberViewStateImpl; - @override - Object? get error; @override TextEditingController get phoneController; @override + TextEditingController get nameController; + @override CountryCode get code; @override bool get isButtonEnable; @override + bool get isForCreateUser; + @override bool get isPop; /// Create a copy of ConfirmNumberViewState diff --git a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart index a272ed5f..19dac949 100644 --- a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart +++ b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart @@ -14,6 +14,7 @@ import 'package:khelo/ui/flow/team/add_team_member/confirm_number_sheet/confirm_ import 'package:khelo/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:style/animations/on_tap_scale.dart'; +import 'package:style/button/action_button.dart'; import 'package:style/button/secondary_button.dart'; import 'package:style/extensions/context_extensions.dart'; import 'package:style/indicator/progress_indicator.dart'; @@ -52,13 +53,33 @@ class _ContactSelectionScreenState return AppPage( title: context.l10n.contact_selection_contact_title, actions: [ - if (state.isActionInProgress) - const Padding( - padding: EdgeInsets.only(right: 16.0), - child: AppProgressIndicator( - size: AppProgressIndicatorSize.small, - ), - ), + (state.isActionInProgress) + ? const Padding( + padding: EdgeInsets.only(right: 16.0), + child: AppProgressIndicator( + size: AppProgressIndicatorSize.small, + ), + ) + : actionButton( + context, + icon: Icon( + Icons.add, + color: context.colorScheme.textPrimary, + ), + onPressed: () async { + final confirmedNumber = await ConfirmNumberSheet.show< + (String, CountryCode, String)>( + context, + isForCreateUser: true, + ); + if (context.mounted && confirmedNumber != null) { + notifier.getUserByPhoneNumber( + confirmedNumber.$1, + "${confirmedNumber.$2.dialCode} ${confirmedNumber.$3}", + ); + } + }, + ), ], body: Builder( builder: (context) => Padding( @@ -210,7 +231,7 @@ class _ContactSelectionScreenState ) async { final (code, number) = notifier.getNormalisedNumber(phoneNumber); final confirmedNumber = - await ConfirmNumberSheet.show<(CountryCode, String)>( + await ConfirmNumberSheet.show<(String, CountryCode, String)>( context, code: code, defaultNumber: number, @@ -218,7 +239,7 @@ class _ContactSelectionScreenState if (context.mounted && confirmedNumber != null) { notifier.getUserByPhoneNumber( displayName, - "${confirmedNumber.$1.dialCode} ${confirmedNumber.$2}", + "${confirmedNumber.$2.dialCode} ${confirmedNumber.$3}", ); } } diff --git a/khelo/macos/Runner.xcodeproj/project.pbxproj b/khelo/macos/Runner.xcodeproj/project.pbxproj index 5461cd44..b3014c8b 100644 --- a/khelo/macos/Runner.xcodeproj/project.pbxproj +++ b/khelo/macos/Runner.xcodeproj/project.pbxproj @@ -212,7 +212,7 @@ 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - A5D109412EFD3ADCDB78BA22 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, + C6EC651590B00B7478981FF0 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */, ); buildRules = ( ); @@ -333,7 +333,7 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - A5D109412EFD3ADCDB78BA22 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { + C6EC651590B00B7478981FF0 /* FlutterFire: "flutterfire upload-crashlytics-symbols" */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( From 5baee4cc4c62387e7abb026340e5d4002c4f1249 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:02:08 +0530 Subject: [PATCH 02/10] deploy function on each push --- .github/workflows/function_deploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index 8f9b163f..4cbbbfbc 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -1,10 +1,10 @@ name: Deploy Firebase Function -on: - push: - branches: - - main - workflow_dispatch: +on: push +# push: +# branches: +# - main +# workflow_dispatch: jobs: deploy: From 22b1c24c35f930050796308bc13c9c179cd8d238 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:10:57 +0530 Subject: [PATCH 03/10] cmp content --- .github/workflows/function_deploy.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index 4cbbbfbc..fc65377a 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -47,11 +47,15 @@ jobs: echo $GOOGLE_APPLICATION_CREDENTIALS | base64 --decode > functions/google-application-credentials.json echo $FIREBASE_JSON_BASE64 | base64 --decode > firebase.json - - name: Deploy Firebase functions + - name: Print Contents run: | cd khelo - export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/functions/google-application-credentials.json - firebase deploy --only functions --non-interactive --debug + echo functions/google-application-credentials.json + + - name: Deploy Firebase functions + run: | + cd khelo/functions + firebase deploy --only functions --debug - name: Remove credentials file if: success() || failure() From 19e5f6b44c36d3ea30dea5007b0b36f16f9f326c Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:13:39 +0530 Subject: [PATCH 04/10] cmp content --- .github/workflows/function_deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index fc65377a..2ce7034f 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -50,11 +50,12 @@ jobs: - name: Print Contents run: | cd khelo - echo functions/google-application-credentials.json + cat functions/google-application-credentials.json - name: Deploy Firebase functions run: | cd khelo/functions + echo google-application-credentials.json firebase deploy --only functions --debug - name: Remove credentials file From 2579540490d8a5d9279fe2f6003da5aa76a6cb27 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:32:18 +0530 Subject: [PATCH 05/10] print list --- .github/workflows/function_deploy.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index 2ce7034f..df65017f 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -47,15 +47,12 @@ jobs: echo $GOOGLE_APPLICATION_CREDENTIALS | base64 --decode > functions/google-application-credentials.json echo $FIREBASE_JSON_BASE64 | base64 --decode > firebase.json - - name: Print Contents - run: | - cd khelo - cat functions/google-application-credentials.json - - name: Deploy Firebase functions run: | - cd khelo/functions - echo google-application-credentials.json + cd khelo + export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/functions/google-application-credentials.json + cd functions + echo ls -a firebase deploy --only functions --debug - name: Remove credentials file From 6038b79fce69f2954133aff4c37c5659ee4d4083 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:34:46 +0530 Subject: [PATCH 06/10] print list --- .github/workflows/function_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index df65017f..78b159ed 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -52,7 +52,7 @@ jobs: cd khelo export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/functions/google-application-credentials.json cd functions - echo ls -a + ls -a firebase deploy --only functions --debug - name: Remove credentials file From f8eedc562e0b517c699e3116336f917dfb1fc33d Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:37:42 +0530 Subject: [PATCH 07/10] without export --- .github/workflows/function_deploy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index 78b159ed..e2fe484c 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -49,9 +49,7 @@ jobs: - name: Deploy Firebase functions run: | - cd khelo - export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/functions/google-application-credentials.json - cd functions + cd khelo/functions ls -a firebase deploy --only functions --debug From 0ed05180d44fa8cf5602674e3083f9782b90e4d9 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 10:49:04 +0530 Subject: [PATCH 08/10] back to normal --- .github/workflows/function_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index e2fe484c..16da57b1 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -49,8 +49,8 @@ jobs: - name: Deploy Firebase functions run: | - cd khelo/functions - ls -a + cd khelo + export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/functions/google-application-credentials.json firebase deploy --only functions --debug - name: Remove credentials file From f5311113db549bf5c44e19379a127ab758d4dd85 Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 11:01:04 +0530 Subject: [PATCH 09/10] run on main --- .github/workflows/function_deploy.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/function_deploy.yml b/.github/workflows/function_deploy.yml index 16da57b1..1f78cc8d 100644 --- a/.github/workflows/function_deploy.yml +++ b/.github/workflows/function_deploy.yml @@ -1,10 +1,10 @@ name: Deploy Firebase Function -on: push -# push: -# branches: -# - main -# workflow_dispatch: +on: + push: + branches: + - main + workflow_dispatch: jobs: deploy: From a43e7070f4bf67072487bf27a52b30e2f33a472c Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Mon, 30 Sep 2024 15:16:10 +0530 Subject: [PATCH 10/10] fix dial code issue --- .../confirm_number_sheet.dart | 2 +- .../confirm_number_view_model.dart | 17 +++++++++---- .../contact_selection_screen.dart | 5 +++- .../contact_selection_view_model.dart | 18 +++++++------- .../contact_selection_view_model.freezed.dart | 24 ++++++++++++++++++- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart index 1d981d1b..09473de9 100644 --- a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart +++ b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_sheet.dart @@ -63,7 +63,7 @@ class _ConfirmNumberSheetState extends ConsumerState { @override void initState() { notifier = ref.read(confirmNumberStateProvider.notifier); - runPostFrame(() => notifier.setDate( + runPostFrame(() => notifier.setData( widget.code, widget.defaultNumber, widget.isForCreateUser)); super.initState(); } diff --git a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart index d30c26b4..bb7d03ff 100644 --- a/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart +++ b/khelo/lib/ui/flow/team/add_team_member/confirm_number_sheet/confirm_number_view_model.dart @@ -21,7 +21,7 @@ class ConfirmNumberViewNotifier extends StateNotifier { ), )); - void setDate( + void setData( CountryCode? code, String? defaultNumber, bool isForCreateUser, @@ -37,14 +37,23 @@ class ConfirmNumberViewNotifier extends StateNotifier { } void onTextChange() { - final isButtonEnabled = state.phoneController.text.length > 3 && - (state.isForCreateUser ? state.nameController.text.length > 3 : true); - state = state.copyWith(isButtonEnable: isButtonEnabled); + final isNameNotEmpty = state.isForCreateUser + ? state.nameController.text.trim().isNotEmpty + : true; + final isPhoneNotEmpty = state.phoneController.text.trim().length > 3; + state = state.copyWith(isButtonEnable: isNameNotEmpty && isPhoneNotEmpty); } void onConfirmTap() { state = state.copyWith(isPop: true); } + + @override + void dispose() { + state.nameController.dispose(); + state.phoneController.dispose(); + super.dispose(); + } } @freezed diff --git a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart index 19dac949..d6812d53 100644 --- a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart +++ b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_screen.dart @@ -38,7 +38,7 @@ class _ContactSelectionScreenState @override void initState() { notifier = ref.read(contactSelectionStateProvider.notifier); - runPostFrame(() => notifier.setDate(widget.memberIds)); + runPostFrame(() => notifier.setData(widget.memberIds)); super.initState(); } @@ -70,6 +70,9 @@ class _ContactSelectionScreenState final confirmedNumber = await ConfirmNumberSheet.show< (String, CountryCode, String)>( context, + code: CountryCode.getCountryCodeByAlpha2( + countryAlpha2Code: state.deviceCountryCode, + ), isForCreateUser: true, ); if (context.mounted && confirmedNumber != null) { diff --git a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.dart b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.dart index 722d9c99..d58f4161 100644 --- a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.dart +++ b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.dart @@ -24,15 +24,15 @@ class ContactSelectionViewNotifier final DeviceService _deviceService; List fetchedContacts = []; List memberIds = []; - String? deviceCountryCode = - WidgetsBinding.instance.platformDispatcher.locale.countryCode; ContactSelectionViewNotifier(this._userService, this._deviceService) - : super(const ContactSelectionState()) { + : super(ContactSelectionState( + deviceCountryCode: WidgetsBinding + .instance.platformDispatcher.locale.countryCode)) { fetchCountryCode(); } - void setDate(List memberIds) { + void setData(List memberIds) { this.memberIds = memberIds; checkContactPermission(); } @@ -50,7 +50,8 @@ class ContactSelectionViewNotifier void fetchCountryCode() async { try { - deviceCountryCode = await _deviceService.countryCode; + final deviceCountryCode = await _deviceService.countryCode; + state = state.copyWith(deviceCountryCode: deviceCountryCode); } catch (e) { debugPrint( "ContactSelectionViewNotifier: Error in fetchCountryCode -> $e"); @@ -120,7 +121,7 @@ class ContactSelectionViewNotifier .where((element) => phoneNumber.startsWith(element.dialCode)) .firstOrNull ?.dialCode; - code = matchedCountryCode ?? deviceCountryCode; + code = matchedCountryCode ?? state.deviceCountryCode; final trimFrom = matchedCountryCode != null ? code?.length : 1; phoneNumber = phoneNumber.substring(trimFrom ?? 1); } else { @@ -130,14 +131,14 @@ class ContactSelectionViewNotifier CountryCode? countryCode; if (code == null) { countryCode = CountryCode.getCountryCodeByAlpha2( - countryAlpha2Code: deviceCountryCode, + countryAlpha2Code: state.deviceCountryCode, ); } else { countryCode = CountryCode.getCountryCodeByDialCode(dialCode: code); // handle default returned US code in case not found if (countryCode.dialCode == "+1" && code != "+1") { countryCode = CountryCode.getCountryCodeByAlpha2( - countryAlpha2Code: deviceCountryCode, + countryAlpha2Code: state.deviceCountryCode, ); } } @@ -162,6 +163,7 @@ class ContactSelectionState with _$ContactSelectionState { const factory ContactSelectionState({ Object? error, Object? actionError, + String? deviceCountryCode, UserModel? selectedUser, @Default(false) bool loading, @Default(false) bool isActionInProgress, diff --git a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.freezed.dart b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.freezed.dart index 6403f311..66cf049f 100644 --- a/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.freezed.dart +++ b/khelo/lib/ui/flow/team/add_team_member/contact_selection/contact_selection_view_model.freezed.dart @@ -18,6 +18,7 @@ final _privateConstructorUsedError = UnsupportedError( mixin _$ContactSelectionState { Object? get error => throw _privateConstructorUsedError; Object? get actionError => throw _privateConstructorUsedError; + String? get deviceCountryCode => throw _privateConstructorUsedError; UserModel? get selectedUser => throw _privateConstructorUsedError; bool get loading => throw _privateConstructorUsedError; bool get isActionInProgress => throw _privateConstructorUsedError; @@ -41,6 +42,7 @@ abstract class $ContactSelectionStateCopyWith<$Res> { $Res call( {Object? error, Object? actionError, + String? deviceCountryCode, UserModel? selectedUser, bool loading, bool isActionInProgress, @@ -69,6 +71,7 @@ class _$ContactSelectionStateCopyWithImpl<$Res, $Res call({ Object? error = freezed, Object? actionError = freezed, + Object? deviceCountryCode = freezed, Object? selectedUser = freezed, Object? loading = null, Object? isActionInProgress = null, @@ -79,6 +82,10 @@ class _$ContactSelectionStateCopyWithImpl<$Res, return _then(_value.copyWith( error: freezed == error ? _value.error : error, actionError: freezed == actionError ? _value.actionError : actionError, + deviceCountryCode: freezed == deviceCountryCode + ? _value.deviceCountryCode + : deviceCountryCode // ignore: cast_nullable_to_non_nullable + as String?, selectedUser: freezed == selectedUser ? _value.selectedUser : selectedUser // ignore: cast_nullable_to_non_nullable @@ -133,6 +140,7 @@ abstract class _$$ContactSelectionStateImplCopyWith<$Res> $Res call( {Object? error, Object? actionError, + String? deviceCountryCode, UserModel? selectedUser, bool loading, bool isActionInProgress, @@ -160,6 +168,7 @@ class __$$ContactSelectionStateImplCopyWithImpl<$Res> $Res call({ Object? error = freezed, Object? actionError = freezed, + Object? deviceCountryCode = freezed, Object? selectedUser = freezed, Object? loading = null, Object? isActionInProgress = null, @@ -170,6 +179,10 @@ class __$$ContactSelectionStateImplCopyWithImpl<$Res> return _then(_$ContactSelectionStateImpl( error: freezed == error ? _value.error : error, actionError: freezed == actionError ? _value.actionError : actionError, + deviceCountryCode: freezed == deviceCountryCode + ? _value.deviceCountryCode + : deviceCountryCode // ignore: cast_nullable_to_non_nullable + as String?, selectedUser: freezed == selectedUser ? _value.selectedUser : selectedUser // ignore: cast_nullable_to_non_nullable @@ -204,6 +217,7 @@ class _$ContactSelectionStateImpl implements _ContactSelectionState { const _$ContactSelectionStateImpl( {this.error, this.actionError, + this.deviceCountryCode, this.selectedUser, this.loading = false, this.isActionInProgress = false, @@ -217,6 +231,8 @@ class _$ContactSelectionStateImpl implements _ContactSelectionState { @override final Object? actionError; @override + final String? deviceCountryCode; + @override final UserModel? selectedUser; @override @JsonKey() @@ -241,7 +257,7 @@ class _$ContactSelectionStateImpl implements _ContactSelectionState { @override String toString() { - return 'ContactSelectionState(error: $error, actionError: $actionError, selectedUser: $selectedUser, loading: $loading, isActionInProgress: $isActionInProgress, alreadyAdded: $alreadyAdded, hasContactPermission: $hasContactPermission, contacts: $contacts)'; + return 'ContactSelectionState(error: $error, actionError: $actionError, deviceCountryCode: $deviceCountryCode, selectedUser: $selectedUser, loading: $loading, isActionInProgress: $isActionInProgress, alreadyAdded: $alreadyAdded, hasContactPermission: $hasContactPermission, contacts: $contacts)'; } @override @@ -252,6 +268,8 @@ class _$ContactSelectionStateImpl implements _ContactSelectionState { const DeepCollectionEquality().equals(other.error, error) && const DeepCollectionEquality() .equals(other.actionError, actionError) && + (identical(other.deviceCountryCode, deviceCountryCode) || + other.deviceCountryCode == deviceCountryCode) && (identical(other.selectedUser, selectedUser) || other.selectedUser == selectedUser) && (identical(other.loading, loading) || other.loading == loading) && @@ -269,6 +287,7 @@ class _$ContactSelectionStateImpl implements _ContactSelectionState { runtimeType, const DeepCollectionEquality().hash(error), const DeepCollectionEquality().hash(actionError), + deviceCountryCode, selectedUser, loading, isActionInProgress, @@ -290,6 +309,7 @@ abstract class _ContactSelectionState implements ContactSelectionState { const factory _ContactSelectionState( {final Object? error, final Object? actionError, + final String? deviceCountryCode, final UserModel? selectedUser, final bool loading, final bool isActionInProgress, @@ -302,6 +322,8 @@ abstract class _ContactSelectionState implements ContactSelectionState { @override Object? get actionError; @override + String? get deviceCountryCode; + @override UserModel? get selectedUser; @override bool get loading;