Skip to content

Commit

Permalink
changes on the front-end
Browse files Browse the repository at this point in the history
  • Loading branch information
njogubless committed Jan 7, 2025
1 parent 5b888b2 commit aaa854a
Show file tree
Hide file tree
Showing 6 changed files with 319 additions and 125 deletions.
11 changes: 11 additions & 0 deletions lib/core/common/styles/spacing_styles.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:devotion/core/constants/sizes.dart';
import 'package:flutter/material.dart';

class TSpacingStyle {
static EdgeInsetsGeometry paddingWithAppBarHeight = const EdgeInsets.only(
top: TSizes.appBarHeight,
left: TSizes.defaultSpace,
bottom: TSizes.defaultSpace,
right: TSizes.defaultSpace,
);
}
74 changes: 74 additions & 0 deletions lib/core/constants/sizes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class TSizes {
//padding and margin heights
static const double xs = 4.0;
static const double sm = 8.0;
static const double md = 16.0;
static const double lg = 24.0;
static const double xl = 32.0;

// Icon sizes

static const double iconXs = 12.0;
static const double iconSm = 16.0;
static const double iconMd = 24.0;
static const double iconLg = 32.0;

// Font sizes

static const double fontSizeSm = 14.0;
static const double fontSizeMd = 16.0;
static const double fontSizeLg = 18.0;

// ButtonSizes

static const double buttonHeight = 18.0;
static const double buttonRadius = 12.0;
static const double buttonWidth = 120.0;
static const double buttonElevation = 4.0;

//AppBar height

static const double appBarHeight = 56.0;

//ImageSizes

static const double imageThumbSize = 80.0;

//default spacing between sections

static const double defaultSpace = 24.0;
static const double spaceBtwItems = 16.0;
static const double spaceBtwSections = 32.0;

//BorderRadius

static const double borderRadiusSm = 4.0;
static const double borderRadiusMd = 8.0;
static const double borderRadiusLg = 12.0;

//Divider Height
static const double dividerHeight = 1.0;

//InputField

static const double inputFieldRadius = 12.0;
static const double spaceBtwinputFields = 16.0;

//Card Sizes

static const double cardRadiusLg = 16.0;
static const double cardRadiusMd = 12.0;
static const double cardRadiusSm = 10.0;
static const double cardRadiusXs = 6.0;
static const double cardElevation = 2.0;

//image Carousel height
static const double imageCarouselHeight = 200.0;

//Loading indicator Size
static const double loadingIndicatorSize = 36.0;

// grid view spacing

static const double gridViewSpacing = 16.0;
}
62 changes: 62 additions & 0 deletions lib/core/util/device/device_utility.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart';

class TDeviceUtils {
static void hideKeyboard(BuildContext context) {
FocusScope.of(context).requestFocus(FocusNode());
}

static Future<void> setStatusBarColor(Color color) async {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: color));
}

static bool isLandscapeOrientation(BuildContext context) {
final viewInsets = View.of(context).viewInsets;
return viewInsets.bottom == 0;
}

static bool isPortraitOrientation(BuildContext context) {
final viewInsets = View.of(context).viewInsets;
return viewInsets.bottom != 0;
}

static void setFullScreen(bool enable) {
SystemChrome.setEnabledSystemUIMode(
enable ? SystemUiMode.immersiveSticky : SystemUiMode.edgeToEdge);
}

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

// static double getScreenWidth(BuildContext context) {
// return MediaQuery.of(context).size.width;
// }

// static double getPixelRatio() {
// return MediaQuery.of(Get.context!).devicePixelRatio;
// }

// static double getStatusBarHeight() {
// return MediaQuery.of(Get.context!).padding.top;
// }

// static bool isIos() {
// return Platform.isIos;
// }

// static bool isndroid() {
// return Platform.isAndroid;
// }

static void launchUrl(String url) async {
if (await canLaunchUrlString(url)) {
await launchUrlString(url);
} else {
throw 'could not launch $url';
}
}
}
33 changes: 27 additions & 6 deletions lib/features/auth/Repository/auth_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,42 @@ class AuthRepository {
}
}

FutureEither<UserModel> signInWithEmailAndPassword(
String email, String password) async {
try {
UserCredential userCredential = await _auth.signInWithEmailAndPassword(
email: email, password: password);

UserModel userModel;

if (userCredential.additionalUserInfo!.isNewUser) {
userModel = UserModel(
uid: userCredential.user!.uid,
isAuthenticated: true,
userEmail: userCredential.user!.email ?? 'No email',
userName: userCredential.user!.displayName ?? 'No name',
role: 'user');
await _users.doc(userCredential.user!.uid).set(userModel.toMap());
} else {
userModel = await getUserData(userCredential.user!.uid).first;
}
return right(userModel);
} on FirebaseAuthException catch (e) {
return left(Failure(e.message ?? 'An error occured'));
} catch (e) {
return left(Failure(e.toString()));
}
}

// getUserdata function
Stream<UserModel> getUserData(String uid) {
// getUserdata function
Stream<UserModel> getUserData(String uid) {
return _users.doc(uid).snapshots().map(
(event) => UserModel.fromMap(event.data() as Map<String, dynamic>));
}



// Sign out the user
Future<void> signOutUser() async {
await _googleSignIn.signOut();
await _auth.signOut();
}


}
10 changes: 1 addition & 9 deletions lib/features/auth/controller/auth_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:flutter/material.dart';
//use the userProvider to update user information
final userProvider = StateProvider<UserModel?>((ref) => null);

final authControllerProvider = StateNotifierProvider<AuthController, bool>(
final authControllerProvider = StateNotifierProvider<AuthController, bool>(
(ref) => AuthController(
authRepository: ref.watch(authRepositoryProvider),
ref: ref,
Expand Down Expand Up @@ -54,10 +54,6 @@ class AuthController extends StateNotifier<bool> {
MaterialPageRoute(builder: (context) => const WelcomeScreen()),
);
}





Stream<UserModel> getUserData(String uid) {
return _authRepository.getUserData(uid);
Expand All @@ -70,8 +66,6 @@ class AuthController extends StateNotifier<bool> {
context, '/login'); // Update to navigate back to the login screen
}



// // Sign up with phone number
// void signUpWithPhoneNumber(String phoneNumber, BuildContext context) {
// _authRepository.signUpWithPhoneNumber(phoneNumber, context);
Expand Down Expand Up @@ -106,6 +100,4 @@ class AuthController extends StateNotifier<bool> {
// void sendPasswordReset(String userEmail, BuildContext context) {
// _authRepository.sendPasswordReset(userEmail, context);
// }


}
Loading

0 comments on commit aaa854a

Please sign in to comment.