Skip to content

Commit

Permalink
cooking πŸ§‘β€πŸ³
Browse files Browse the repository at this point in the history
  • Loading branch information
olawills committed Oct 17, 2023
1 parent 6c3200d commit 8f1f9ee
Show file tree
Hide file tree
Showing 50 changed files with 1,549 additions and 601 deletions.
1 change: 1 addition & 0 deletions lib/app/common/constants/app_constant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ double height = 852.h;
double width = 393.w;

const Duration veryLongDuration = Duration(seconds: 3);
const Duration nearbyUsers = Duration(seconds: 5);

const profileUrl =
"https://media.istockphoto.com/id/1451587807/vector/user-profile-icon-vector-avatar-or-person-icon-profile-picture-portrait-symbol-vector.jpg?s=612x612&w=0&k=20&c=yDJ4ITX1cHMh25Lt1vI1zBn2cAKKAlByHBvPJ8gEiIg=";
Expand Down
2 changes: 1 addition & 1 deletion lib/app/common/constants/app_sizes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SizeOf {
static double carouselWidth = 264.sp;
static double carouselHeight = 254.sp;
static double carouselBodyHeight = 54.sp;
static double carouselBodyWidth = 262.sp;
static double carouselBodyWidth = 270.sp;
static double similarTasteWidth = 258.sp;
static double similarTasteHeight = 225.sp;

Expand Down
6 changes: 6 additions & 0 deletions lib/app/common/extensions/onpadding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ extension OnPaddingColumn on Column {
}
}

extension OnPaddingContainer on Container {
Widget padding(EdgeInsets edgeInsets) {
return Padding(padding: edgeInsets.h, child: this);
}
}

extension OnPaddingWidget on Widget {
Widget padding(EdgeInsets edgeInsets) {
return Padding(padding: edgeInsets.w, child: this);
Expand Down
19 changes: 19 additions & 0 deletions lib/app/common/themes/app_theme.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import '../../core/core.dart';
import '../constants/app_style.dart';

class AppThemes {
static final AppThemes _instance = AppThemes._();

factory AppThemes() => _instance;
AppThemes._();

final theme = ThemeData.light().copyWith(
textTheme: TextTheme(
titleLarge: AppTextStyle.titleLarge,
titleMedium: AppTextStyle.titleMedium,
titleSmall: AppTextStyle.titleSmall,
bodyLarge: AppTextStyle.bodyLarge,
bodyMedium: AppTextStyle.bodyMedium,
bodySmall: AppTextStyle.bodySmall,
));
}
2 changes: 2 additions & 0 deletions lib/app/core/config/app_string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ class AppString {
static String lastMsg = 'is a perfect match for you';
static String verifySuccess = 'Verified Successfully';
static String passwordReset = 'Otp has been sent to your email ';
static String signupSucess = 'User Signup Successfully';
static String allowGps = 'Please allow Gps permission';
}
15 changes: 8 additions & 7 deletions lib/app/core/config/injection_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import '../../../src/features/cubit/internet_connection/internet_connection_cubi
import '../../../src/features/home/data/datasources/user_remote_data_source.dart';
import '../../../src/features/home/data/repository/user_repository.dart';
import '../../../src/features/home/presentation/bloc/gps/gps_bloc.dart';
import '../../../src/features/home/presentation/bloc/location/location_bloc.dart';
import '../../../src/features/home/presentation/bloc/users/users_bloc.dart';
import '../network/dio_client.dart';
import '../network/dio_helper.dart';

GetIt serviceLocator = GetIt.instance;

Expand All @@ -29,6 +30,7 @@ class ServiceLocator {
serviceLocator.registerFactory<FetchUserBloc>(() => FetchUserBloc());
serviceLocator.registerFactory<InterestBloc>(() => InterestBloc());
serviceLocator.registerFactory<GpsBloc>(() => GpsBloc());
serviceLocator.registerFactory<LocationBloc>(() => LocationBloc());

// Cubit
serviceLocator
Expand All @@ -37,10 +39,10 @@ class ServiceLocator {
() => InternetConnectionCubit(connectivity: serviceLocator()));

// Data Source
serviceLocator
.registerFactory<AuthRemoteDataSource>(() => AuthRemoteDataSource());
serviceLocator
.registerFactory<UserRemoteDataSource>(() => UserRemoteDataSource());
serviceLocator.registerFactory<AuthRemoteDataSource>(
() => AuthRemoteDataSourceImpl());
serviceLocator.registerFactory<UserRemoteDataSource>(
() => UserRemoteDataSourceImpl());
serviceLocator.registerFactory<AuthInfoRemoteDataSource>(
() => AuthInfoRemoteDataSourceImpl());

Expand All @@ -51,8 +53,7 @@ class ServiceLocator {
serviceLocator.registerFactory<UserRepository>(() => UserRepository());

// Dio
serviceLocator.registerLazySingleton<DioClient>(
() => DioClient(serviceLocator<Dio>()));
serviceLocator.registerLazySingleton<DioHelper>(() => DioHelper());
serviceLocator.registerLazySingleton<Dio>(() => Dio());
serviceLocator.registerLazySingleton<Connectivity>(() => Connectivity());
}
Expand Down
5 changes: 4 additions & 1 deletion lib/app/core/domain/all_blocs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:dating_app/src/auth/presentation/bloc/auth_bloc/auth_bloc.dart';

import '../../../src/auth/presentation/bloc/user_info_bloc/interest_bloc.dart';
import '../../../src/features/home/presentation/bloc/gps/gps_bloc.dart';
import '../../../src/features/home/presentation/bloc/location/location_bloc.dart';
import '../../../src/startup/presentation/bloc/onboarding_bloc.dart';

class AppBlocProviders {
Expand All @@ -23,7 +24,9 @@ class AppBlocProviders {
create: (context) => serviceLocator<InterestBloc>()),

BlocProvider<GpsBloc>(create: (context) => serviceLocator<GpsBloc>()),


BlocProvider<LocationBloc>(
create: (context) => serviceLocator<LocationBloc>()),
// BottomNavBar Cubit
BlocProvider<BottomNavigationCubit>(
create: (context) => serviceLocator<BottomNavigationCubit>()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:dating_app/app/core/core.dart';
import 'package:dating_app/app/core/routes/app_router.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../common/themes/app_theme.dart';

class SparkzConfig extends StatelessWidget {
const SparkzConfig({super.key});

Expand All @@ -26,6 +28,7 @@ class SparkzConfig extends StatelessWidget {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
title: kAppName,
theme: AppThemes().theme,
routerConfig: AppRouter.routerConfig,
locale: context.locale,
localizationsDelegates: context.localizationDelegates,
Expand Down
17 changes: 0 additions & 17 deletions lib/app/core/network/dio_client.dart

This file was deleted.

47 changes: 47 additions & 0 deletions lib/app/core/network/dio_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:dating_app/app/core/network/dio_interceptors.dart';
import 'package:dio/dio.dart';

import '../services/api_url.dart';

class DioHelper {
static Dio dio = Dio();

static void init() {
dio = Dio(
BaseOptions(
baseUrl: ApiConfig.baseUrl,
receiveDataWhenStatusError: true,
connectTimeout: ApiConfig.connectionTimeout,
receiveTimeout: ApiConfig.receiveTimeout,
sendTimeout: const Duration(milliseconds: 20000),
),
);
dio.interceptors.add(DioInterceptor());
}

static Future<Response> postData({
required String path,
Map<String, dynamic>? query,
required String data,
String? token,
}) async {
dio.options.headers = ApiConfig.header;
return await dio.post(
path,
queryParameters: query,
data: data,
);
}

static Future<Response> getData({
required String path,
Map<String, dynamic>? query,
String? token,
}) async {
dio.options.headers = ApiConfig.header;
return await dio.get(
path,
queryParameters: query,
);
}
}
2 changes: 2 additions & 0 deletions lib/app/core/services/api_url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ApiConfig {

ApiConfig._internal();
static const String baseUrl = 'https://spark-dating-api.onrender.com/api/v1';
static const String apikey = 'AIzaSyC6FjHR9e9VmVWl28hQRBYauAIPSNGtLXw';
static String locationUrl(double latitude, double longitude) => 'https://maps.googleapis.com/maps/api/geocode/json?latlng=$latitude,$longitude&key=$apikey';

static const Duration receiveTimeout = Duration(milliseconds: 20000);
static const Duration connectionTimeout = Duration(milliseconds: 20000);
Expand Down
8 changes: 5 additions & 3 deletions lib/app/core/services/auth_local_data_source.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:dating_app/app/common/common.dart';
import 'package:dating_app/src/auth/data/models/user.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand All @@ -16,6 +15,7 @@ class LocalDataStorage {
return _prefs!;
}

final String _id = 'userId';
final String _firstName = AppTokens.firstName;
final String _lastName = AppTokens.lastName;
final String _email = AppTokens.email;
Expand All @@ -36,21 +36,23 @@ class LocalDataStorage {

Future<void> setuserInfo(User data) async {
final pref = await instance.prefs;
await pref.setString(_id, data.id);
await pref.setString(_firstName, data.firstName);
await pref.setString(_lastName, data.lastName);
await pref.setString(_email, data.email);
await pref.setString(_token, data.token);
await pref.setString(_profilePicture, Assets.noAccountImage);
await pref.setString(_profilePicture, data.profilePicture);
await pref.setBool(_loggedIn, true);
}

Future<void> setLoginResponse(LoginResponse data) async {
final pref = await instance.prefs;
await pref.setString(_id, data.user.id);
await pref.setString(_firstName, data.user.firstName);
await pref.setString(_lastName, data.user.lastName);
await pref.setString(_email, data.user.email);
await pref.setString(_token, data.token);
await pref.setString(_profilePicture, Assets.noAccountImage);
await pref.setString(_profilePicture, data.user.profilePicture);
await pref.setBool(_loggedIn, true);
}

Expand Down
33 changes: 33 additions & 0 deletions lib/app/core/services/geolocation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:convert';

import 'package:dio/dio.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

import '../../../../../app/core/services/api_url.dart';

class GeolocationService {
static final GeolocationService instance = GeolocationService._init();

factory GeolocationService() {
return instance;
}
GeolocationService._init();

Future<String> reverseGeolocation(LatLng position) async {
final uri =
Uri.parse(ApiConfig.locationUrl(position.latitude, position.longitude));
final response = await Dio().getUri(uri);
if (response.statusCode == 200) {
final data = json.decode(response.data);
final results = data['results'] as List;
if (results.isNotEmpty) {
final address = results[0]['formatted_address'];
return address;
} else {
return 'Unknown location';
}
} else {
throw Exception('Failed to reverse geocode location');
}
}
}
4 changes: 4 additions & 0 deletions lib/app/core/services/services.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export 'api_url.dart';
export 'app_tokens.dart';
export 'auth_local_data_source.dart';
export 'geolocation.dart';
63 changes: 63 additions & 0 deletions lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that looks up messages for specific locales by
// delegating to the appropriate library.

// Ignore issues from commonly used lints in this file.
// ignore_for_file:implementation_imports, file_names, unnecessary_new
// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering
// ignore_for_file:argument_type_not_assignable, invalid_assignment
// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases
// ignore_for_file:comment_references

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
import 'package:intl/src/intl_helpers.dart';

import 'messages_en.dart' as messages_en;

typedef Future<dynamic> LibraryLoader();
Map<String, LibraryLoader> _deferredLibraries = {
'en': () => new SynchronousFuture(null),
};

MessageLookupByLibrary? _findExact(String localeName) {
switch (localeName) {
case 'en':
return messages_en.messages;
default:
return null;
}
}

/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) {
var availableLocale = Intl.verifiedLocale(
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return new SynchronousFuture(false);
}
var lib = _deferredLibraries[availableLocale];
lib == null ? new SynchronousFuture(false) : lib();
initializeInternalMessageLookup(() => new CompositeMessageLookup());
messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
return new SynchronousFuture(true);
}

bool _messagesExistFor(String locale) {
try {
return _findExact(locale) != null;
} catch (e) {
return false;
}
}

MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
var actualLocale =
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
if (actualLocale == null) return null;
return _findExact(actualLocale);
}
25 changes: 25 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
// This is a library that provides messages for a en locale. All the
// messages from the main program should be duplicated here with the same
// function name.

// Ignore issues from commonly used lints in this file.
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';

final messages = new MessageLookup();

typedef String MessageIfAbsent(String messageStr, List<dynamic> args);

class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{};
}
Loading

0 comments on commit 8f1f9ee

Please sign in to comment.