Skip to content

Commit

Permalink
change usecases name
Browse files Browse the repository at this point in the history
  • Loading branch information
aidaiym committed Mar 27, 2024
1 parent 9f7a470 commit 2a170a6
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/lib/app/data/data.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export 'repository/app_repositoty_impl.dart';
export 'repository/theme_repository_impl.dart';
export 'repository/auth_repositoty_impl.dart';
export 'models/user_model.dart';
export 'source/app_local_data_source.dart';
export 'source/theme_local_data_source.dart';
export 'source/auth_local_data_source.dart';
export 'source/auth_remote_data_source.dart';
export 'models/user_model.dart';
2 changes: 1 addition & 1 deletion app/lib/app/domain/domain.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export 'repository/app_repositoty.dart';
export 'repository/theme_repository.dart';
export 'repository/auth_repository.dart';
export 'entity/user_entity.dart';
export 'usecase/get_initial_locale_use_case.dart';
export 'usecase/get_initial_theme_use_case.dart';
export 'usecase/set_color_use_case.dart';
Expand All @@ -10,3 +9,4 @@ export 'usecase/set_mode_use_case.dart';
export 'usecase/get_initial_user_use_case.dart';
export 'usecase/login_use_case.dart';
export 'usecase/set_gender_use_case.dart';
export 'entity/user_entity.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class GetCurrentLocaleUseCase {

final AppRepository appRepository;

Locale get getCurrentLocale {
Locale get call {
return appRepository.getLocale;
}
}
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/get_initial_user_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class GetInitialUserUseCase {

final AuthRepository repository;

UserEntity? get init {
UserEntity? get call {
return repository.init;
}
}
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/login_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class LoginUseCase {

final AuthRepository repository;

Future<Either<UserEntity, Exception>> login(String languageCode, Gender gender) async {
Future<Either<UserEntity, Exception>> call(String languageCode, Gender gender) async {
return repository.login(languageCode, gender);
}
}
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/set_color_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class SetColorUseCase {

final ThemeRepository themeRepository;

Future<void> setColor(int index, Color color) async {
Future<void> call(int index, Color color) async {
await themeRepository.saveThemePrimaryColor(index);
}
}
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/set_gender_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class SetGenderUseCase {

final AuthRepository repository;

Future<void> saveGender(Gender gender) async {
Future<void> call(Gender gender) async {
return repository.saveGender(gender);
}
}
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/set_locale_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class SetLocaleUseCase {

final AppRepository appRepository;

Future<Locale?> setLocal(String langKey) async {
Future<Locale?> call(String langKey) async {
await appRepository.setLocale(langKey);
return Locale(langKey);
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/app/domain/usecase/set_mode_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class SetModeUseCase {

final ThemeRepository themeRepository;

Future<void> setMode({required bool isDark}) async {
Future<void> call({required bool isDark}) async {
await themeRepository.saveThemeMode(isDark: isDark);
}
}
8 changes: 4 additions & 4 deletions app/lib/app/presentation/cubit/app_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppCubit extends Cubit<AppState> {
required this.getInitialThemeUseCase,
required this.setModeUseCase,
required this.setColorUseCase,
}) : super(AppState(getLocalLocaleUseCase.getCurrentLocale, getInitialThemeUseCase.call));
}) : super(AppState(getLocalLocaleUseCase.call, getInitialThemeUseCase.call));

final GetCurrentLocaleUseCase getLocalLocaleUseCase;
final SetLocaleUseCase setLocaleUseCase;
Expand All @@ -23,17 +23,17 @@ class AppCubit extends Cubit<AppState> {
final SetColorUseCase setColorUseCase;

Future<void> changeLang(String langKey) async {
final local = await setLocaleUseCase.setLocal(langKey);
final local = await setLocaleUseCase.call(langKey);
emit(state.copyWith(currentLocale: local));
}

Future<void> changeMode({required bool isDark}) async {
await setModeUseCase.setMode(isDark: isDark);
await setModeUseCase.call(isDark: isDark);
emit(state.copyWith(theme: state.theme.copyWith(brightness: isDark ? Brightness.dark : Brightness.light)));
}

Future<void> changeColor(int index, Color color) async {
await setColorUseCase.setColor(index, color);
await setColorUseCase.call(index, color);
emit(state.copyWith(theme: state.theme.copyWith(targetColor: color)));
}

Expand Down
6 changes: 3 additions & 3 deletions app/lib/app/presentation/cubit/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class AuthCubit extends Cubit<AuthState> {
this.getInitialUserUseCase,
this.loginUseCase,
this.setGenderUseCase,
) : super(AuthState(user: getInitialUserUseCase.init));
) : super(AuthState(user: getInitialUserUseCase.call));

final GetInitialUserUseCase getInitialUserUseCase;
final LoginUseCase loginUseCase;
final SetGenderUseCase setGenderUseCase;

Future<AuthState> login(String languageCode, Gender gender) async {
final user = await loginUseCase.login(languageCode, gender);
final user = await loginUseCase.call(languageCode, gender);
user.fold(
(l) => emit(state.copyWith(exception: l)),
(r) => emit(state.copyWith(user: r)),
Expand All @@ -26,7 +26,7 @@ class AuthCubit extends Cubit<AuthState> {
}

Future<void> setGender(Gender gender) async {
await setGenderUseCase.saveGender(gender);
await setGenderUseCase.call(gender);
emit(state.copyWith(user: state.user?.copyWith(gender: gender)));
}

Expand Down

0 comments on commit 2a170a6

Please sign in to comment.