Skip to content

Commit

Permalink
writing helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
njogubless committed Jan 8, 2025
1 parent c12da26 commit f15837d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 28 deletions.
53 changes: 27 additions & 26 deletions lib/core/common/styles/login_Signup_widgets/form_divider.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
// import 'package:devotion/core/constants/colors.dart';
// import 'package:flutter/material.dart';
import 'package:devotion/core/constants/colors.dart';
import 'package:devotion/core/constants/helper_functions.dart';
import 'package:flutter/material.dart';

// class TFormDivider extends StatelessWidget {
// TFormDivider({super.key, required this.dividerText});
class TFormDivider extends StatelessWidget {
const TFormDivider({super.key, required this.dividerText});

// final String dividerText;
final String dividerText;

// @override
// Widget build(BuildContext context) {
// //final dark = THelperFunctions.isDarkMode(context);
// return Row(
// children: [
// Flexible(child: Divider(
// color: dark ? TColors.darkGrey : TColors.grey,
// thickness: 0.5,
// indent:60,
// endIndent: 5,
// )),
// Text(dividerText,style: Theme.of(context).textTheme.labelMedium,),
// Flexible(child: Divider(
// color: dark ? TColors.darkGrey : TColors.grey,
// thickness: 0.5,
// indent:60,
// endIndent: 5,)),
// ],
// );
// }
// }
@override
Widget build(BuildContext context) {
final dark = THelperFunctions.isDarkMode(context);
return Row(
children: [
Flexible(child: Divider(
color: dark ? TColors.darkGrey : TColors.grey,
thickness: 0.5,
indent:60,
endIndent: 5,
)),
Text(dividerText,style: Theme.of(context).textTheme.labelMedium,),
Flexible(child: Divider(
color: dark ? TColors.darkGrey : TColors.grey,
thickness: 0.5,
indent:60,
endIndent: 5,)),
],
);
}
}
37 changes: 37 additions & 0 deletions lib/core/constants/helper_functions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';

class THelperFunctions {
static void navigateToScreen(BuildContext context, Widget screen) {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => screen),
);
}

static String truncateText(String text, int maxLength) {
if (text.length <= maxLength) {
return text;
} else {
return '${text.substring(0, maxLength)}...';
}
}

static bool isDarkMode(BuildContext context) {
return Theme.of(context).brightness == Brightness.dark;
}

// static Size screenSize() {
// return MediaQuery.of(Get.context!).size;
// }


// static Size screenHeight() {
// return MediaQuery.of(Get.context!).size.height;
// }

// static Size screenWidth() {
// return MediaQuery.of(Get.context!).size.width;
// }


}
8 changes: 7 additions & 1 deletion lib/features/auth/presentation/screen/sign_up.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
// }
// }

import 'package:devotion/core/common/styles/login_Signup_widgets/form_divider.dart';
import 'package:devotion/core/common/styles/login_Signup_widgets/social_button.dart';
import 'package:devotion/core/common/styles/text_strings.dart';
import 'package:devotion/core/constants/sizes.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -223,7 +225,11 @@ class SignUpScreen extends StatelessWidget {
child: const Text( TTexts.createAccount)),
)
],
))
)),
//divider
TFormDivider(dividerText: TTexts.orSignupWith),
//social Button
const TSocialButton(),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/features/auth/presentation/screen/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SplashScreen extends ConsumerWidget {
} else {
// User is not signed in, navigate to sign-up screen
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => SignUpPage()),
MaterialPageRoute(builder: (context) => const SignUpScreen()),
);
}
});
Expand Down

0 comments on commit f15837d

Please sign in to comment.