Skip to content

Commit

Permalink
feat: 기본해시태그, 폴더,해시 상세 새로고침,페이지네이션 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
nain93 committed Aug 17, 2023
1 parent b46138e commit c1c3722
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 129 deletions.
3 changes: 1 addition & 2 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">moa_app</string>
<string name="app_name">모아</string>
<string name="client_id">K10uUCEMBAnAY0ZtJMeo</string>
<string name="client_secret">qtCW1qORKI</string>
<string name="client_name">Moa-app</string>
<string name="default_web_client_id">152179311533-i1kbu0metfct55ga0a3elf21ddihjcfd.apps.googleusercontent.com</string>
</resources>
2 changes: 1 addition & 1 deletion ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Moa</string>
<string>모아</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand Down
3 changes: 2 additions & 1 deletion lib/navigations/main_bottom_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class MainBottomTab extends HookConsumerWidget {

useEffect(() {
/// 외부에서 url 공유로 들어왔을경우 폴더선택화면으로 이동
if (receiveUrl.value.isNotEmpty &&
if (context.mounted &&
receiveUrl.value.isNotEmpty &&
lifeCycle == AppLifecycleState.resumed) {
context.go(
GoRoutes.folderSelect.fullPath,
Expand Down
17 changes: 13 additions & 4 deletions lib/providers/folder_detail_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ part 'folder_detail_provider.g.dart';
// @Riverpod(keepAlive: true)
@riverpod
class FolderDetail extends _$FolderDetail {
Future<List<ContentModel>> fetchItem({required String folderName}) async {
Future<List<ContentModel>> fetchItem({
required String folderName,
int? page,
int? size,
}) async {
// get the [KeepAliveLink]
var link = ref.keepAlive();
// a timer to be used by the callbacks below
Expand All @@ -33,11 +37,16 @@ class FolderDetail extends _$FolderDetail {
timer?.cancel();
});

var data =
FolderRepository.instance.getFolderDetailList(folderName: folderName);
var data = FolderRepository.instance.getFolderDetailList(
folderName: folderName,
page: page,
size: size,
);
return data;
}

@override
Future<void> build() async {}
Future<List<ContentModel>?> build() async {
return null;
}
}
9 changes: 5 additions & 4 deletions lib/providers/hashtag_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ part 'hashtag_provider.g.dart';
// @Riverpod(keepAlive: true)
@riverpod
class Hashtag extends _$Hashtag {
Future<List<HashtagModel>> fetchItem() async {
Future<(List<HashtagModel>, List<HashtagModel>)> fetchItem() async {
var data = HashtagRepository.instance.getHashtagList();
return data;
}

@override
Future<List<HashtagModel>> build() async {
Future<(List<HashtagModel>, List<HashtagModel>)> build() async {
return fetchItem();
}

Expand Down Expand Up @@ -50,7 +50,7 @@ class Hashtag extends _$Hashtag {
});
}

Future<List<HashtagModel>?> addHashtag({
Future<void> addHashtag({
required String hashtag,
}) async {
state = const AsyncValue.loading();
Expand All @@ -60,7 +60,8 @@ class Hashtag extends _$Hashtag {
var data = await fetchItem();
return data;
});
return;

return state.value;
// return state.value;
}
}
8 changes: 6 additions & 2 deletions lib/providers/hashtag_view_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ part 'hashtag_view_provider.g.dart';
// @Riverpod(keepAlive: true)
@riverpod
class HashtagView extends _$HashtagView {
Future<(List<ContentModel>, int)> fetchItem({String? hashtag}) async {
Future<(List<ContentModel>, int)> fetchItem({
int? page,
int? size,
String? hashtag,
}) async {
var token = ref.watch(tokenStateProvider).value;

// get the [KeepAliveLink]
Expand All @@ -38,7 +42,7 @@ class HashtagView extends _$HashtagView {
});

var data = await HashtagRepository.instance
.getHashtagView(tag: hashtag, token: token);
.getHashtagView(tag: hashtag, token: token, page: page, size: size);
return data;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/repositories/content_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abstract class IContentRepository {
Future<void> addContent({
required AddContentType contentType,
required ContentModel content,
required String hashTagStringList,
String? hashTagStringList,
});

Future<ContentModel> getContentDetail({
Expand Down Expand Up @@ -41,7 +41,7 @@ class ContentRepository implements IContentRepository {
Future<void> addContent({
required AddContentType contentType,
required ContentModel content,
required String hashTagStringList,
String? hashTagStringList,
}) async {
var token = await TokenRepository.instance.getToken();
if (contentType == AddContentType.image) {
Expand All @@ -55,9 +55,7 @@ class ContentRepository implements IContentRepository {
'hashTag': hashTagStringList,
'contentType': 'IMAGE',
'originalFileName': '${content.contentName}.png',
'image': content.thumbnailImageUrl == ''
? ''
: 'image/png:base64:${content.thumbnailImageUrl}',
'image': 'image/png:base64:${content.thumbnailImageUrl}',
},
options: Options(
headers: {
Expand All @@ -79,7 +77,9 @@ class ContentRepository implements IContentRepository {
'contentType': 'URL',
'url': content.contentUrl,
'originalFileName': '${content.contentName}.png',
'image': 'image/png:base64:${content.thumbnailImageUrl}',
'image': content.thumbnailImageUrl == ''
? ''
: 'image/png:base64:${content.thumbnailImageUrl}',
},
options: Options(
headers: {
Expand Down
9 changes: 6 additions & 3 deletions lib/repositories/folder_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ class FolderRepository implements IFolderRepository {
}

@override
Future<List<ContentModel>> getFolderDetailList(
{required String folderName}) async {
Future<List<ContentModel>> getFolderDetailList({
required String folderName,
int? page = 1,
int? size = 10,
}) async {
var token = await TokenRepository.instance.getToken();

var res = await dio.get(
'/api/v1/folder/detail/view?folderName=$folderName',
'/api/v1/folder/detail/view?page=$page&size=$size&folderName=$folderName',
options: Options(
headers: {
'Authorization': 'Bearer $token',
Expand Down
15 changes: 10 additions & 5 deletions lib/repositories/hashtag_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class IHashtagRepository {
int? size,
String? tag,
});
Future<List<HashtagModel>> getHashtagList();
Future<(List<HashtagModel>, List<HashtagModel>)> getHashtagList();
Future<void> editHashtag({
required String tagId,
required String hashtags,
Expand Down Expand Up @@ -59,7 +59,7 @@ class HashtagRepository implements IHashtagRepository {
}

@override
Future<List<HashtagModel>> getHashtagList() async {
Future<(List<HashtagModel>, List<HashtagModel>)> getHashtagList() async {
var token = await TokenRepository.instance.getToken();

var res = await dio.get(
Expand All @@ -71,9 +71,14 @@ class HashtagRepository implements IHashtagRepository {
),
);

return res.data['data']['users']
.map<HashtagModel>((e) => HashtagModel.fromJson(e))
.toList();
return (
res.data['data']['users']
.map<HashtagModel>((e) => HashtagModel.fromJson(e))
.toList() as List<HashtagModel>,
res.data['data']['default']
.map<HashtagModel>((e) => HashtagModel.fromJson(e))
.toList() as List<HashtagModel>
);
}

@override
Expand Down
24 changes: 12 additions & 12 deletions lib/screens/add_content/add_image_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class AddImageContent extends HookConsumerWidget {
}

void completeAddContent() async {
if (imageFile.value == null ||
title.value.isEmpty ||
selectedTagList.value.where((e) => e.isSelected).isEmpty) {
if (imageFile.value == null || title.value.isEmpty) {
if (imageFile.value == null) {
imageError.value = '이미지를 선택해주세요.';
}
Expand All @@ -74,10 +72,6 @@ class AddImageContent extends HookConsumerWidget {
titleError.value = '제목을 입력해주세요.';
}

if (selectedTagList.value.where((e) => e.isSelected).isEmpty) {
tagError.value = '태그를 선택해주세요.';
}

return;
}

Expand All @@ -92,7 +86,7 @@ class AddImageContent extends HookConsumerWidget {
}
}).toList();

var hashTagStringList = selectTag.join(',');
var hashTagStringList = selectTag.isEmpty ? selectTag.join(',') : null;

try {
await ContentRepository.instance.addContent(
Expand Down Expand Up @@ -161,10 +155,16 @@ class AddImageContent extends HookConsumerWidget {

useEffect(() {
if (hashtagAsync.hasValue) {
selectedTagList.value = hashtagAsync.value!
.map((e) => SelectedTagModel(
tagId: e.tagId, name: e.hashTag, isSelected: false))
.toList();
selectedTagList.value = [
...hashtagAsync.value!.$2
.map((e) => SelectedTagModel(
tagId: e.tagId, name: e.hashTag, isSelected: false))
.toList(),
...hashtagAsync.value!.$1
.map((e) => SelectedTagModel(
tagId: e.tagId, name: e.hashTag, isSelected: false))
.toList()
];
}
return null;
}, [hashtagAsync.isLoading]);
Expand Down
23 changes: 12 additions & 11 deletions lib/screens/add_content/add_link_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ class AddLinkContent extends HookConsumerWidget {
}

void completeAddContent() async {
if (link.value.isEmpty ||
title.value.isEmpty ||
selectedTagList.value.where((e) => e.isSelected).isEmpty) {
if (link.value.isEmpty || title.value.isEmpty) {
if (link.value.isEmpty) {
linkError.value = '링크를 입력해주세요.';
}
Expand All @@ -97,10 +95,6 @@ class AddLinkContent extends HookConsumerWidget {
titleError.value = '제목을 입력해주세요.';
}

if (selectedTagList.value.where((e) => e.isSelected).isEmpty) {
tagError.value = '태그를 선택해주세요.';
}

return;
}
loading.value = true;
Expand All @@ -120,7 +114,7 @@ class AddLinkContent extends HookConsumerWidget {
}
}).toList();

var hashTagStringList = selectTag.join(',');
var hashTagStringList = selectTag.isEmpty ? selectTag.join(',') : null;

try {
await ContentRepository.instance.addContent(
Expand Down Expand Up @@ -196,9 +190,16 @@ class AddLinkContent extends HookConsumerWidget {

useEffect(() {
if (hashtagAsync.hasValue) {
selectedTagList.value = hashtagAsync.value!
.map((e) => SelectedTagModel(name: e.hashTag, isSelected: false))
.toList();
selectedTagList.value = [
...hashtagAsync.value!.$2
.map((e) => SelectedTagModel(
tagId: e.tagId, name: e.hashTag, isSelected: false))
.toList(),
...hashtagAsync.value!.$1
.map((e) => SelectedTagModel(
tagId: e.tagId, name: e.hashTag, isSelected: false))
.toList()
];
}
return null;
}, [hashtagAsync.isLoading]);
Expand Down
4 changes: 3 additions & 1 deletion lib/screens/home/content_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class ContentView extends HookConsumerWidget {
}
}

void pressConfirm() {}
void pressConfirm() {
context.pop();
}

void editContent() {
isEditMode.value = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/home/edit_content_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class ChangeHashtagList extends HookConsumerWidget {
hashtagAsync.when(
data: (data) {
if (selectedTagList.value.isEmpty) {
selectedTagList.value = data.map((e) {
selectedTagList.value = data.$1.map((e) {
if (hashtagList.value.contains(e.hashTag)) {
return SelectedTagModel(
name: e.hashTag, isSelected: true);
Expand Down
Loading

0 comments on commit c1c3722

Please sign in to comment.