Skip to content

Commit

Permalink
Merge pull request #44 from pet-sitter/40-user-회원가입-로직-구현
Browse files Browse the repository at this point in the history
Feat: [회원가입] 유저 회원가입 로직 구현
  • Loading branch information
Yellowtoast authored Jan 15, 2024
2 parents 2ba7ec9 + 2bfbe21 commit 655a737
Show file tree
Hide file tree
Showing 127 changed files with 2,765 additions and 3,313 deletions.
88 changes: 44 additions & 44 deletions ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions lib/api/user_api.dart

This file was deleted.

2 changes: 2 additions & 0 deletions lib/app/di/app_binding.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:pets_next_door_flutter/app/di/modules/auth_di.dart';
import 'package:pets_next_door_flutter/app/di/modules/user_di.dart';

final class AppBinder {
Expand All @@ -11,6 +12,7 @@ final class AppBinder {
_initTopPriority();

for (final di in [
AuthDependencyInjection(),
UserDependencyInjection(),
]) {
di.init();
Expand Down
40 changes: 40 additions & 0 deletions lib/app/di/modules/auth_di.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:pets_next_door_flutter/app/di/feature_di_interface.dart';
import 'package:pets_next_door_flutter/app/di/locator.dart';
import 'package:pets_next_door_flutter/features/auth/auth.dart';
import 'package:pets_next_door_flutter/features/auth/data/remote/auth_remote_data_source_impl.dart';
import 'package:pets_next_door_flutter/features/auth/repositories/auth_repository_impl.dart';
import 'package:pets_next_door_flutter/features/auth/auth.dart';
import 'package:pets_next_door_flutter/features/auth/usecases/sign_in_oauth_use_case.dart';

final class AuthDependencyInjection extends FeatureDependencyInjection {
@override
void dataSources() {
locator.registerLazySingleton<AuthRemoteDataSource>(
AuthRemoteDataSourceImpl.new,
);
}

@override
void repositories() {
locator.registerLazySingleton<AuthRepository>(
() => AuthRepositoryImpl(
authRemoteDataSource,
),
);
}

@override
void useCases() {
locator
..registerFactory(
() => SignInOAuthUseCase(
authRepository,
),
)
..registerFactory(
() => SignOutUseCase(
authRepository,
),
);
}
}
8 changes: 7 additions & 1 deletion lib/app/di/modules/user_di.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:pets_next_door_flutter/features/user/data/local/user_local_data_
import 'package:pets_next_door_flutter/features/user/data/local/user_local_data_source_impl.dart';
import 'package:pets_next_door_flutter/features/user/data/remote/user_remote_data_source_impl.dart';
import 'package:pets_next_door_flutter/features/user/repositories/user_repository_impl.dart';
import 'package:pets_next_door_flutter/features/user/usecases/create_user_data_use_case.dart';
import 'package:pets_next_door_flutter/features/user/user.dart';

final class UserDependencyInjection extends FeatureDependencyInjection {
Expand Down Expand Up @@ -38,10 +39,15 @@ final class UserDependencyInjection extends FeatureDependencyInjection {
userRepository,
),
)
..registerFactory(
..registerFactory<UpdateUserTokenLocalUseCase>(
() => UpdateUserTokenLocalUseCase(
userRepository,
),
)
..registerFactory<CreateUserDataUseCase>(
() => CreateUserDataUseCase(
userRepository,
),
);
}
}
60 changes: 26 additions & 34 deletions lib/app/router/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:pets_next_door_flutter/app/router/scaffold_with_nested_navigation.dart';
import 'package:pets_next_door_flutter/features/user/domain/user_profile_view_state.dart';
import 'package:pets_next_door_flutter/presentation/pages/chat/chat_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/gather/gather_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/home/home_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/my_info/profile_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/pet/register_pet_page.dart';
import 'package:pets_next_door_flutter/presentation/pages/pet/steps/breed_search_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/sign_in/sign_in_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/sign_up/phone_auth_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/sign_in/sign_in_page.dart';
import 'package:pets_next_door_flutter/presentation/pages/sign_up/sign_up_page.dart';
import 'package:pets_next_door_flutter/presentation/pages/splash/splash_page.dart';
import 'package:pets_next_door_flutter/presentation/pages/user/user_profile_view.dart';
import 'package:pets_next_door_flutter/presentation/pages/user/user_view.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'app_router.g.dart';
Expand All @@ -21,70 +19,65 @@ final rootNavigatorKey = GlobalKey<NavigatorState>();
final _homeNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'home');
final _gatherNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'gather');
final _chatNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'chat');
final _userNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'user');
final _myInfoNavigatorKey = GlobalKey<NavigatorState>(debugLabel: 'my');

enum AppRoute {
splash,
signIn,
signUp,
phoneAuth,
home,
gather,
chat,
user,
myInfo,
profile,
breedSearch,
registerPet,
registerPet;

const AppRoute();

String get path => '/${this.name}';
}

@riverpod
// ignore: unsupported_provider_value
GoRouter goRouter(GoRouterRef ref) {
return GoRouter(
initialLocation: '/${AppRoute.splash}',
initialLocation: AppRoute.splash.path,
navigatorKey: rootNavigatorKey,
debugLogDiagnostics: true,
redirect: (context, state) {
return null;
},
routes: [
GoRoute(
path: '/${AppRoute.splash}',
path: AppRoute.splash.path,
name: AppRoute.splash.name,
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
child: SplashPage(),
child: SplashView(),
),
),
GoRoute(
path: '/signIn',
path: AppRoute.signIn.path,
name: AppRoute.signIn.name,
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
child: SignInView(),
),
),
GoRoute(
path: '/phoneAuth',
name: AppRoute.phoneAuth.name,
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
child: PhoneAuthView(),
child: SignInPage(),
),
),

GoRoute(
path: '/profile',
name: AppRoute.profile.name,
path: AppRoute.signUp.path,
name: AppRoute.signUp.name,
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
child: UserProfileView(
profileViewState: state.extra! as UserProfileViewState,
),
child: SignUpPage(),
),
),

GoRoute(
path: '/breedSearch',
path: AppRoute.breedSearch.path,
name: AppRoute.breedSearch.name,
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
Expand All @@ -93,7 +86,7 @@ GoRouter goRouter(GoRouterRef ref) {
),

GoRoute(
path: '/${AppRoute.registerPet.name}',
path: AppRoute.registerPet.path,
name: AppRoute.registerPet.name,
pageBuilder: (context, state) => MaterialPage(
key: state.pageKey,
Expand All @@ -120,7 +113,7 @@ GoRouter goRouter(GoRouterRef ref) {
routes: [
// Products
GoRoute(
path: '/home',
path: AppRoute.home.path,
name: AppRoute.home.name,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
Expand Down Expand Up @@ -168,15 +161,14 @@ GoRouter goRouter(GoRouterRef ref) {
],
),
StatefulShellBranch(
navigatorKey: _userNavigatorKey,
navigatorKey: _myInfoNavigatorKey,
routes: [
// Shopping Cart
GoRoute(
path: '/user',
name: AppRoute.user.name,
path: AppRoute.myInfo.path,
name: AppRoute.myInfo.name,
pageBuilder: (context, state) => NoTransitionPage(
key: state.pageKey,
child: UserView(),
child: MyInfoView(),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/app/router/app_router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions lib/app/router/scaffold_with_nested_navigation.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
import 'package:pets_next_door_flutter/app/router/app_router.dart';
import 'package:pets_next_door_flutter/core/constants/images.dart';
import 'package:pets_next_door_flutter/core/constants/svgs.dart';
import 'package:pets_next_door_flutter/core/localization/string_hardcoded.dart';
import 'package:pets_next_door_flutter/presentation/providers/user/user_auth_provider.dart';

// Stateful navigation based on:
// https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/stateful_shell_route.dart
Expand Down Expand Up @@ -61,6 +65,16 @@ class ScaffoldWithBottomNavBar extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
body: body,
floatingActionButton: Consumer(
builder: (BuildContext context, WidgetRef ref, Widget? child) {
return FloatingActionButton(onPressed: () async {
final signOutSucceed =
await ref.read(userAuthProvider.notifier).signOut();

if (signOutSucceed) ref.context.goNamed(AppRoute.signIn.name);
});
},
),
bottomNavigationBar: SizedBox(
height: 60,
child: Wrap(children: [
Expand All @@ -78,10 +92,10 @@ class ScaffoldWithBottomNavBar extends StatelessWidget {

BottomNavigationBarItem(
icon: SvgPicture.asset(
PNDImages.home,
PNDSvgs.home,
),
activeIcon: SvgPicture.asset(
PNDImages.home,
PNDSvgs.home,
color: Color(0xffFF8B00),
),
label: '',
Expand Down
16 changes: 1 addition & 15 deletions lib/core/constants/images.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
class PNDImages {
abstract class PNDImages {
static const String cat = 'assets/imgs/pet/cat.png';
static const String dog = 'assets/imgs/pet/dog.png';

static const String mainIcon = 'assets/svgs/main_icon.svg';
static const String mainTitleIcon = 'assets/svgs/main_title_icon.svg';
static const String google = 'assets/svgs/login/google_icon.svg';
static const String kakao = 'assets/svgs/login/kakao_icon.svg';
static const String apple = 'assets/svgs/login/apple_icon.svg';

static const String home = 'assets/svgs/home/icon_home.svg';
static const String community = 'assets/svgs/home/icon_community.svg';
static const String chat = 'assets/svgs/home/icon_chat.svg';
static const String user = 'assets/svgs/home/icon_user.svg';

static const String catActive = 'assets/svgs/pet/cat_active.svg';
static const String dogActive = 'assets/svgs/pet/dog_active.svg';
}
15 changes: 15 additions & 0 deletions lib/core/constants/svgs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
abstract class PNDSvgs {
static const String mainIcon = 'assets/svgs/main_icon.svg';
static const String mainTitleIcon = 'assets/svgs/main_title_icon.svg';
static const String google = 'assets/svgs/login/google_icon.svg';
static const String kakao = 'assets/svgs/login/kakao_icon.svg';
static const String apple = 'assets/svgs/login/apple_icon.svg';

static const String home = 'assets/svgs/home/icon_home.svg';
static const String community = 'assets/svgs/home/icon_community.svg';
static const String chat = 'assets/svgs/home/icon_chat.svg';
static const String user = 'assets/svgs/home/icon_user.svg';

static const String catActive = 'assets/svgs/pet/cat_active.svg';
static const String dogActive = 'assets/svgs/pet/dog_active.svg';
}
17 changes: 17 additions & 0 deletions lib/core/enums/media_type.enum.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:pets_next_door_flutter/core/network_handling/exceptions/custom_exception.dart';

enum MediaType {
image('image'),
video('video');

const MediaType(this.code);

final code;

factory MediaType.getByTypeStr({required String type}) {
return MediaType.values.firstWhere(
(element) => element.code == type,
orElse: () => throw ParsingEnumException(),
);
}
}
5 changes: 5 additions & 0 deletions lib/core/enums/sns_provider_type.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import 'package:freezed_annotation/freezed_annotation.dart';

enum SnsProviderType {
@JsonValue('kakao')
kakao(providerId: 'kakao.com'),
@JsonValue('google')
google(providerId: 'google.com'),
@JsonValue('apple')
apple(providerId: 'apple.com');

const SnsProviderType({required this.providerId});
Expand Down
26 changes: 26 additions & 0 deletions lib/core/helper/validation_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
extension StringValidationExt on String {
// 공백 존재 여부
bool get hasSpace {
return RegExp(r'\s').hasMatch(this);
}

/// 적합한 문자 사용 여부
/// 한글, 알파벳, 숫자, 언더스코어(_), 하이픈(-)만 사용할 수 있음
bool get hasProperCharacter {
return RegExp(r'^[a-zA-Z0-9ㄱ-ㅎ가-힣_-]+$').hasMatch(trim());
}

/// 2-10자 사이의 닉네임 길이 여부
bool get hasProperNicknameLength {
return RegExp(r'^{2,10}$').hasMatch(trim());
}

/// 욕설, 비속어 필터링 정규식
bool get hasContainFWord {
return trim().contains(
RegExp(
r'시발|병신|[시씨슈쓔쉬쉽쒸쓉]([0-9]*|[0-9]+ *)[바발벌빠빡빨뻘파팔펄]|[섊좆좇졷좄좃좉졽썅춍]|ㅅㅣㅂㅏㄹ?|ㅂ[0-9]*ㅅ|[ㅄᄲᇪᄺᄡᄣᄦᇠ]|[ㅅㅆᄴ][0-9]*[ㄲㅅㅆᄴㅂ]|[존좉좇][0-9 ]*나|[자보][0-9]+지|보빨|[봊봋봇봈볻봁봍] *[빨이]|[후훚훐훛훋훗훘훟훝훑][장앙]|후빨|[엠앰]창|애[미비]|애자|[^탐]색기|([샊샛세쉐쉑쉨쉒객갞갟갯갰갴겍겎겏겤곅곆곇곗곘곜걕걖걗걧걨걬] *[끼키퀴])|새 *[키퀴]|[병븅]신|미친[가-닣닥-힣]|[믿밑]힌|[염옘]병|[샊샛샜샠섹섺셋셌셐셱솃솄솈섁섂섓섔섘]기|[섹섺섻쎅쎆쎇쎽쎾쎿섁섂섃썍썎썏][스쓰]|지랄|니[애에]미|갈[0-9]*보[^가-힣]|[뻐뻑뻒뻙뻨][0-9]*[뀨큐킹낑)|꼬추|곧휴|[가-힣]슬아치|자박꼼|[병븅]딱|빨통|[사싸](이코|가지|까시)|육시[랄럴]|육실[알얼할헐]|즐[^가-힣]|찌(질이|랭이)|찐따|찐찌버거|창[녀놈]|[가-힣]{2,}충[^가-힣]|[가-힣]{2,}츙|부녀자|화냥년|환[양향]년|호[구모]|조[선센][징]|조센|[쪼쪽쪾]([발빨]이|[바빠]리)|盧|무현|찌끄[레래]기|(하악){2,}|하[앍앜]|[낭당랑앙항남담람암함][ ]?[가-힣]+[띠찌]|느[금급]마|文在|在寅|(?<=[^\n])[家哥]|속냐|[tT]l[qQ]kf|Wls',
),
);
}
}
3 changes: 0 additions & 3 deletions lib/core/network_handling/app_dio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class _AppDio with DioMixin implements Dio {
receiveTimeout: Duration(milliseconds: 30000),
sendTimeout: Duration(milliseconds: 30000),
receiveDataWhenStatusError: true,
headers: <String, dynamic>{
'accept': 'application/json',
},
);

(transformer as BackgroundTransformer).jsonDecodeCallback = parseJson;
Expand Down
Loading

0 comments on commit 655a737

Please sign in to comment.