Skip to content

Commit

Permalink
Merge pull request #67 from devsadeq/feature/enhancement
Browse files Browse the repository at this point in the history
Feature/enhancement
  • Loading branch information
devsadeq authored Nov 3, 2022
2 parents c8456fb + 6b6ca48 commit 9126205
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 47 deletions.
2 changes: 2 additions & 0 deletions lib/app/core/theme/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class AppTheme {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14.r),
),
disabledBackgroundColor: blueColor,
disabledForegroundColor: backgroundColor,
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SubmitBottomSheet extends StatelessWidget {
SizedBox(height: 50.h),
CustomButton(
title: "Back To Home",
onTap: () => Get.close(2),
onTap: () async => Get.close(2),
),
],
);
Expand Down
19 changes: 10 additions & 9 deletions lib/app/modules/auth/controllers/auth_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,19 @@ class AuthController extends GetxController {
_rxCountry.value = "+${country.dialCode}";
}

void onLoginSubmit() {
Future<void> onLoginSubmit() async {
if (loginFormKey.currentState!.validate()) {
_login();
await _login();
}
}

void onRegisterSubmit() {
Future<void> onRegisterSubmit() async {
if (registerType == RegisterType.CUSTOMER &&
customerFormKey.currentState!.validate()) {
_registerCustomer();
} else if (companyFormKey.currentState!.validate()) {
_registerCompany();
await _registerCustomer();
} else if (registerType == RegisterType.COMPANY &&
companyFormKey.currentState!.validate()) {
await _registerCompany();
}
}

Expand All @@ -146,7 +147,7 @@ class AuthController extends GetxController {
result.whenOrNull(success: (data) => Get.offAllNamed(Routes.LOGIN));
}

void _login() async {
Future<void> _login() async {
_rxLoginState.value = await _authRepository.login(
dto: LoginInDto(
emailOrPhone: loginEmailController.text,
Expand All @@ -171,7 +172,7 @@ class AuthController extends GetxController {
);
}

void _registerCustomer() async {
Future<void> _registerCustomer() async {
_rxRegisterCustomerState.value = await _authRepository.registerCustomer(
dto: RegisterCustomerDto(
name: customerFullNameController.text,
Expand All @@ -198,7 +199,7 @@ class AuthController extends GetxController {
);
}

void _registerCompany() async {
Future<void> _registerCompany() async {
_rxRegisterCompanyState.value = await _authRepository.registerCompany(
dto: RegisterCompanyDto(
name: companyNameController.text,
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/auth/views/login/widgets/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Body extends GetView<AuthController> {
btnLabel: AppStrings.loginBtn,
firstTextSpan: AppStrings.youDoNotHaveAnAccountYet,
secondTextSpan: AppStrings.signup,
onTap: () => controller.onLoginSubmit(),
onTap: controller.onLoginSubmit,
onTextTap: controller.onSignUp,
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/auth/views/register/widgets/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Body extends GetView<AuthController> {
btnLabel: AppStrings.signup.toUpperCase(),
firstTextSpan: AppStrings.alreadyHaveAnAccount,
secondTextSpan: AppStrings.signIn,
onTap: controller.onRegisterSubmit,
onTap: controller.onRegisterSubmit,
onTextTap: () => Get.offNamed(Routes.LOGIN),
),
SizedBox(height: 50.h),
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/auth/views/widgets/button_with_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ButtonWithText extends StatelessWidget {
final String btnLabel;
final String firstTextSpan;
final String secondTextSpan;
final void Function() onTap;
final Future<void> Function() onTap;
final void Function() onTextTap;

@override
Expand Down
7 changes: 3 additions & 4 deletions lib/app/modules/root/controllers/root_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ class RootController extends GetxController {
}

void logout() {
Dialogs.questionDialog(
title: "Are you sure you want\nto logout?",
btnOkText: "Yes, logout",
btnCancelOnPress: () {},
Dialogs.warningDialog(
title: "You are about to logout",
btnOkText: "Logout",
btnOkOnPress: AuthController.to.logout,
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/app/modules/saved/controllers/saved_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SavedController extends GetxController {
super.onClose();
}

jumpToHome() {
Future<void> jumpToHome() async {
_rootController.persistentTabController.jumpToTab(0);
}

Expand Down
9 changes: 4 additions & 5 deletions lib/app/modules/saved/views/widgets/no_saving.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:jobs_flutter_app/app/modules/root/controllers/root_controller.dart';
import 'package:jobs_flutter_app/app/modules/saved/controllers/saved_controller.dart';
import 'package:jobs_flutter_app/app/routes/app_pages.dart';
import 'package:jobs_flutter_app/app/widgets/custom_button.dart';

import '../../../../core/values/strings.dart';
import '../../../../widgets/custom_button.dart';
import '../../controllers/saved_controller.dart';

class NoSaving extends GetView<SavedController> {
const NoSaving({Key? key}) : super(key: key);
Expand Down Expand Up @@ -45,7 +44,7 @@ class NoSaving extends GetView<SavedController> {
padding: EdgeInsets.symmetric(horizontal: 80.w),
child: CustomButton(
title: "FIND A JOB",
onTap: () => controller.jumpToHome(),
onTap: controller.jumpToHome,
),
)
],
Expand Down
18 changes: 8 additions & 10 deletions lib/app/modules/waiting/views/widgets/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class Body extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Center(
return Padding(
padding: EdgeInsets.all(29.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(height: 250.h),
Text(
AppStrings.thankYou,
style: GoogleFonts.poppins(
Expand All @@ -38,16 +39,13 @@ class Body extends StatelessWidget {
style: GoogleFonts.poppins(
fontSize: 14.sp,
fontWeight: FontWeight.w400,
color: Get.theme.colorScheme.tertiary,
color: Get.theme.colorScheme.secondary,
),
),
SizedBox(height: 210.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 29.w),
child: CustomButton(
title: AppStrings.exit,
onTap: () => SystemNavigator.pop(),
),
SizedBox(height: 100.h),
CustomButton(
title: AppStrings.exit,
onTap: () => SystemNavigator.pop(),
),
],
),
Expand Down
35 changes: 27 additions & 8 deletions lib/app/widgets/custom_button.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class CustomButton extends StatelessWidget {
const CustomButton({
CustomButton({
Key? key,
required this.title,
required this.onTap,
}) : super(key: key);
final String title;
final void Function() onTap;
final Future<void> Function() onTap;

final RxBool _isLoading = false.obs;

@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: onTap,
style: Get.theme.elevatedButtonTheme.style,
child: FittedBox(child: Text(title)),
return Obx(
() => SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _isLoading.value
? null
: () async {
_isLoading.value = true;
await onTap();
_isLoading.value = false;
},
style: Get.theme.elevatedButtonTheme.style,
child: FittedBox(
child: _isLoading.value
? SizedBox(
height: 20.h,
width: 20.h,
child: const CircularProgressIndicator(color: Colors.white),
)
: Text(title),
),
),
),
);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/app/widgets/custom_save_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ class CustomSaveButtonState extends State<CustomSaveButton>
? SizedBox(
height: widget.size,
width: widget.size,
child: const Center(
child: CupertinoActivityIndicator(),
child: Center(
child: CupertinoActivityIndicator(
color: widget.color,
),
),
)
: HeroIcon(
Expand Down
13 changes: 9 additions & 4 deletions lib/app/widgets/dialogs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import 'custom_lottie.dart';

class Dialogs {
static Future<bool>? warningDialog({
required String title,
required String description,
String? title = AppStrings.DIALOG_QUESTION_TITLE,
String? description,
String? btnOkText = AppStrings.DIALOG_BTN_APPROVE,
required Function() btnOkOnPress,
}) {
AwesomeDialog(
Expand All @@ -19,10 +20,14 @@ class Dialogs {
animType: AnimType.bottomSlide,
title: title,
desc: description,
btnOkText: AppStrings.DIALOG_BTN_OK,
btnCancelText: AppStrings.DIALOG_BTN_CANCEL,
btnOkText: btnOkText,
showCloseIcon: true,
btnOkOnPress: btnOkOnPress,
headerAnimationLoop: false,
dialogBorderRadius: BorderRadius.circular(16.r),
buttonsBorderRadius: BorderRadius.circular(14.r),
padding: EdgeInsets.only(bottom: 12.w),
btnOkColor: Get.theme.colorScheme.primary,
).show();
}

Expand Down

0 comments on commit 9126205

Please sign in to comment.