Skip to content

Commit

Permalink
Add user via name and contact (#106)
Browse files Browse the repository at this point in the history
* add user via name and contact

* deploy function on each push

* cmp content

* cmp content

* print list

* print list

* without export

* back to normal

* run on main

* fix dial code issue
  • Loading branch information
cp-sidhdhi-p authored Sep 30, 2024
1 parent 9a91a5b commit fac2295
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/function_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: |
cd khelo
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/functions/google-application-credentials.json
firebase deploy --only functions --non-interactive --debug
firebase deploy --only functions --debug
- name: Remove credentials file
if: success() || failure()
Expand Down
2 changes: 2 additions & 0 deletions khelo/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions khelo/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion khelo/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,6 @@ SPEC CHECKSUMS:
TOCropViewController: 80b8985ad794298fb69d3341de183f33d1853654
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: d498f76935296deef3b8cdc54d2f1c29ab5e4e95
PODFILE CHECKSUM: 263bbdc4af357de40d8d908cfc1d29ff7d1f184b

COCOAPODS: 1.15.2
26 changes: 13 additions & 13 deletions khelo/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T?> show<T>(
BuildContext context, {
CountryCode? code,
String? defaultNumber,
bool isForCreateUser = false,
}) {
HapticFeedback.mediumImpact();
return showModalBottomSheet(
Expand All @@ -37,6 +39,7 @@ class ConfirmNumberSheet extends ConsumerStatefulWidget {
child: ConfirmNumberSheet(
code: code,
defaultNumber: defaultNumber,
isForCreateUser: isForCreateUser,
),
);
},
Expand All @@ -47,6 +50,7 @@ class ConfirmNumberSheet extends ConsumerStatefulWidget {
super.key,
this.code,
this.defaultNumber,
this.isForCreateUser = false,
});

@override
Expand All @@ -59,7 +63,8 @@ class _ConfirmNumberSheetState extends ConsumerState<ConfirmNumberSheet> {
@override
void initState() {
notifier = ref.read(confirmNumberStateProvider.notifier);
runPostFrame(() => notifier.setDate(widget.code, widget.defaultNumber));
runPostFrame(() => notifier.setData(
widget.code, widget.defaultNumber, widget.isForCreateUser));
super.initState();
}

Expand All @@ -78,11 +83,39 @@ class _ConfirmNumberSheetState extends ConsumerState<ConfirmNumberSheet> {
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,
Expand All @@ -99,47 +132,43 @@ class _ConfirmNumberSheetState extends ConsumerState<ConfirmNumberSheet> {
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(),
),
],
),
),
],
),
);
}
Expand Down Expand Up @@ -173,8 +202,9 @@ class _ConfirmNumberSheetState extends ConsumerState<ConfirmNumberSheet> {
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));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,21 @@ class ConfirmNumberViewNotifier extends StateNotifier<ConfirmNumberViewState> {
ConfirmNumberViewNotifier()
: super(ConfirmNumberViewState(
phoneController: TextEditingController(),
nameController: TextEditingController(),
code: CountryCode.getCountryCodeByAlpha2(
countryAlpha2Code:
WidgetsBinding.instance.platformDispatcher.locale.countryCode,
),
));

void setDate(CountryCode? code, String? defaultNumber) {
void setData(
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();
}

Expand All @@ -33,22 +37,33 @@ class ConfirmNumberViewNotifier extends StateNotifier<ConfirmNumberViewState> {
}

void onTextChange() {
state = state.copyWith(
isButtonEnable: state.phoneController.text.length > 3);
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
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;
}
Loading

0 comments on commit fac2295

Please sign in to comment.