Skip to content

Commit

Permalink
feat: 해시태그 추가 api
Browse files Browse the repository at this point in the history
  • Loading branch information
nain93 committed Aug 13, 2023
1 parent ebe823c commit 3d290c1
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 292 deletions.
60 changes: 0 additions & 60 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,16 @@ PODS:
- AppAuth/Core
- Firebase/CoreOnly (10.12.0):
- FirebaseCore (= 10.12.0)
- Firebase/Messaging (10.12.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.12.0)
- firebase_core (2.15.0):
- Firebase/CoreOnly (= 10.12.0)
- Flutter
- firebase_messaging (14.6.5):
- Firebase/Messaging (= 10.12.0)
- firebase_core
- Flutter
- FirebaseCore (10.12.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreInternal (10.12.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.12.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseMessaging (10.12.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleDataTransport (~> 9.2)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Reachability (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- nanopb (< 2.30910.0, >= 2.30908.0)
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_native_splash (0.0.1):
- Flutter
- flutter_naver_login (0.0.1):
Expand All @@ -55,31 +32,15 @@ PODS:
- google_sign_in_ios (0.0.1):
- Flutter
- GoogleSignIn (~> 6.2)
- GoogleDataTransport (9.2.3):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleSignIn (6.2.4):
- AppAuth (~> 1.5)
- GTMAppAuth (~> 1.3)
- GTMSessionFetcher/Core (< 3.0, >= 1.1)
- GoogleUtilities/AppDelegateSwizzler (7.11.4):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.4):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.4):
- GoogleUtilities/Environment
- GoogleUtilities/Network (7.11.4):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.4)"
- GoogleUtilities/Reachability (7.11.4):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.11.4):
- GoogleUtilities/Logger
- GTMAppAuth (1.3.1):
- AppAuth/Core (~> 1.6)
- GTMSessionFetcher/Core (< 3.0, >= 1.5)
Expand All @@ -90,11 +51,6 @@ PODS:
- Flutter
- kakao_flutter_sdk_common (1.5.0):
- Flutter
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- naveridlogin-sdk-ios (4.1.6)
- path_provider_foundation (0.0.1):
- Flutter
Expand All @@ -119,9 +75,7 @@ PODS:

DEPENDENCIES:
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- flutter_naver_login (from `.symlinks/plugins/flutter_naver_login/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
Expand All @@ -145,27 +99,19 @@ SPEC REPOS:
- Firebase
- FirebaseCore
- FirebaseCoreInternal
- FirebaseInstallations
- FirebaseMessaging
- FMDB
- GoogleDataTransport
- GoogleSignIn
- GoogleUtilities
- GTMAppAuth
- GTMSessionFetcher
- nanopb
- naveridlogin-sdk-ios
- PromisesObjC

EXTERNAL SOURCES:
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_messaging:
:path: ".symlinks/plugins/firebase_messaging/ios"
Flutter:
:path: Flutter
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
flutter_naver_login:
Expand Down Expand Up @@ -203,28 +149,22 @@ SPEC CHECKSUMS:
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
Firebase: 07150e75d142fb9399f6777fa56a187b17f833a0
firebase_core: e477125798fc37cd4ab43ca6a8536bf7e0929c00
firebase_messaging: 334d68c3a36b6d4d5cd91e4f42509e0d4ae49828
FirebaseCore: f86a1394906b97ac445ae49c92552a9425831bed
FirebaseCoreInternal: 950500ad8a08963657f6d8c67b579740c06d6aa1
FirebaseInstallations: 7b99ef103f013624444c614397038219c45f8e63
FirebaseMessaging: bb2c4f6422a753038fe137d90ae7c1af57251316
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
flutter_naver_login: 1dbf6d21aae5235cdf76a28ac79cf6871899282f
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
flutter_web_auth: c25208760459cec375a3c39f6a8759165ca0fa4d
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
google_sign_in_ios: 1256ff9d941db546373826966720b0c24804bcdd
GoogleDataTransport: f0308f5905a745f94fb91fea9c6cbaf3831cb1bd
GoogleSignIn: 5651ce3a61e56ca864160e79b484cd9ed3f49b7a
GoogleUtilities: c63691989bf362ba0505507da00eeb326192e83e
GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
integration_test: 13825b8a9334a850581300559b8839134b124670
kakao_flutter_sdk_common: ceb36a134b53ae973da184f67f39993142377af4
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
naveridlogin-sdk-ios: cdd34e3585a3d5aaf37c1d84c1f41faba4a25d1a
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
Expand Down
5 changes: 3 additions & 2 deletions lib/providers/hashtag_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ class Hashtag extends _$Hashtag {
}

Future<List<HashtagModel>?> addHashtag({
required HashtagModel hashtag,
required String hashtag,
}) async {
state = const AsyncValue.loading();

state = await AsyncValue.guard(() async {
await HashtagRepository.instance.addHashtag(hashTag: hashtag);
var data = await fetchItem();
return [hashtag, ...data];
return data;
});

return state.value;
Expand Down
4 changes: 2 additions & 2 deletions lib/providers/token_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class TokenState extends _$TokenState {
return await TokenRepository.instance.getToken();
}

Future<String?> addToken(String token) async {
Future<void> addToken(String token) async {
state = const AsyncValue.loading();

state = await AsyncValue.guard(() async {
return token;
});
return null;
}

Future<void> removeToken() async {
state = const AsyncValue.loading();

state = await AsyncValue.guard(() async {
await TokenRepository.instance.removeToken();
return null;
});
}
Expand Down
10 changes: 10 additions & 0 deletions lib/providers/user_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ class UserState extends _$UserState {
return fetchItem();
});
}

Future<void> withDraw() async {
state = const AsyncValue.loading();

state = await AsyncValue.guard(() async {
await UserRepository.instance.withdrawUser();
await ref.read(tokenStateProvider.notifier).removeToken();
return fetchItem();
});
}
}
9 changes: 6 additions & 3 deletions lib/repositories/auth_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,12 @@ class AuthRepository implements IAuthRepository {
late NaverLoginResult user;

// Non web Naver login option
user = await FlutterNaverLogin.logIn();
token = await FlutterNaverLogin.currentAccessToken;
user = await FlutterNaverLogin.logIn().timeout(
const Duration(seconds: 8),
onTimeout: () => throw '로그인 시간이 초과되었습니다. 다시 시도해주세요.',
);

token = await FlutterNaverLogin.currentAccessToken;
if (user.status != NaverLoginStatus.loggedIn) {
return AuthDto.fail();
}
Expand Down Expand Up @@ -249,7 +252,7 @@ class AuthRepository implements IAuthRepository {
if (credential.identityToken != null && credential.userIdentifier != null) {
return await _loginAndSetTokenWith(AuthDto.success(
id: credential.userIdentifier!,
email: credential.email!,
email: credential.email ?? '',
token: credential.identityToken!,
platform: 'apple',
));
Expand Down
18 changes: 18 additions & 0 deletions lib/repositories/hashtag_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ abstract class IHashtagRepository {
Future<void> deleteHashtag({
required List<String> tagIds,
});
Future<void> addHashtag({
required String hashTag,
});
}

class HashtagRepository implements IHashtagRepository {
Expand Down Expand Up @@ -108,4 +111,19 @@ class HashtagRepository implements IHashtagRepository {
),
);
}

@override
Future<void> addHashtag({required String hashTag}) async {
var token = await TokenRepository.instance.getToken();

await dio.post(
'/api/v1/hashtag/create',
data: {'hashTag': hashTag},
options: Options(
headers: {
'Authorization': 'Bearer $token',
},
),
);
}
}
4 changes: 2 additions & 2 deletions lib/repositories/user_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:moa_app/utils/api.dart';

abstract class IUserRepository {
Future<UserModel?> getUser({String? token});
Future<void> removeUser();
Future<void> withdrawUser();
Future<void> editUserNickname({required String nickname});
}

Expand Down Expand Up @@ -46,7 +46,7 @@ class UserRepository implements IUserRepository {
}

@override
Future<void> removeUser() async {
Future<void> withdrawUser() async {
var token = await TokenRepository.instance.getToken();
await dio.post(
'/api/v1/user/withdrawal',
Expand Down
7 changes: 5 additions & 2 deletions lib/screens/setting/widgets/edit_hashtag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EditHashtag extends HookConsumerWidget {

var updatedHashtagName = useState('');

void addHashtag() {
void addHashtag() async {
if (textController.text.isEmpty) {
return;
}
Expand All @@ -42,7 +42,10 @@ class EditHashtag extends HookConsumerWidget {
return;
}

// todo 유저에 해시태그 추가하기 api
await ref
.read(hashtagProvider.notifier)
.addHashtag(hashtag: textController.text);

selectedTagList.value = [
SelectedTagModel(
isSelected: false,
Expand Down
6 changes: 2 additions & 4 deletions lib/screens/setting/withdraw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:moa_app/constants/color_constants.dart';
import 'package:moa_app/constants/font_constants.dart';
import 'package:moa_app/providers/token_provider.dart';
import 'package:moa_app/repositories/token_repository.dart';
import 'package:moa_app/providers/user_provider.dart';
import 'package:moa_app/utils/router_provider.dart';
import 'package:moa_app/widgets/app_bar.dart';
import 'package:moa_app/widgets/button.dart';
Expand All @@ -21,8 +20,7 @@ class Withdraw extends HookConsumerWidget {

void onPressedWithdraw() async {
try {
await TokenRepository.instance.removeToken();
await ref.read(tokenStateProvider.notifier).removeToken();
await ref.read(userStateProvider.notifier).withDraw();
if (context.mounted) {
context.go(GoRoutes.signIn.fullPath);
}
Expand Down
Loading

0 comments on commit 3d290c1

Please sign in to comment.