Skip to content

Commit

Permalink
[feat/#197] 내 폴더 담기 다이얼로그 UI 작성 및 코드 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
boring-km committed Oct 11, 2023
1 parent 8ab3d27 commit b50579e
Show file tree
Hide file tree
Showing 24 changed files with 158 additions and 89 deletions.
2 changes: 1 addition & 1 deletion lib/const/consts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ const reportReasons = [
'SLANDER',
'SPAM',
'PERSONAL_INFO',
'OTHER'
'OTHER',
];
6 changes: 3 additions & 3 deletions lib/cubits/folders/get_user_folders_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:ac_project_app/provider/api/folders/folder_api.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class GetUserFoldersCubit extends Cubit<FolderList> {
GetUserFoldersCubit(): super(FolderList([]));
GetUserFoldersCubit(): super(const FolderList([]));

final FolderApi folderApi = getIt();

Expand All @@ -16,11 +16,11 @@ class GetUserFoldersCubit extends Cubit<FolderList> {
emit(FolderList(list));
},
error: (msg) {
emit(FolderList([]));
emit(const FolderList([]));
},
);
} catch (e) {
emit(FolderList([]));
emit(const FolderList([]));
}
}
}
2 changes: 1 addition & 1 deletion lib/cubits/links/upload_link_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:ac_project_app/cubits/links/upload_result_state.dart';
import 'package:ac_project_app/util/url_loader.dart';
import 'package:ac_project_app/di/set_up_get_it.dart';
import 'package:ac_project_app/models/link/link.dart';
import 'package:ac_project_app/models/link/upload_type.dart';
import 'package:ac_project_app/provider/api/folders/link_api.dart';
import 'package:ac_project_app/util/logger.dart';
import 'package:ac_project_app/util/string_utils.dart';
import 'package:ac_project_app/util/url_loader.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class UploadLinkCubit extends Cubit<UploadResultState> {
Expand Down
12 changes: 8 additions & 4 deletions lib/models/job/topic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class Topic {
_name = name;
}

Topic.fromJson(dynamic json) {
_id = json['id'] as int?;
_name = json['name'] as String?;
}

static List<Topic> fromJsonList(List<dynamic> jsonList) {
final result = <Topic>[];
for (final json in jsonList) {
Expand All @@ -15,12 +20,9 @@ class Topic {
return result;
}

Topic.fromJson(dynamic json) {
_id = json['id'] as int?;
_name = json['name'] as String?;
}
int? _id;
String? _name;

Topic copyWith({
int? id,
String? name,
Expand All @@ -29,7 +31,9 @@ class Topic {
id: id ?? _id,
name: name ?? _name,
);

int? get id => _id;

String? get name => _name;

Map<String, dynamic> toJson() {
Expand Down
17 changes: 13 additions & 4 deletions lib/models/user/detail_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DetailUser extends Equatable {
json['job_group'] != null ? JobGroup.fromJson(json['job_group']) : null;
_profile_img = json['profile_img'] as String?;
}

late final int? _id;
late final String? _nickname;
late final JobGroup? _jobGroup;
Expand All @@ -39,9 +40,13 @@ class DetailUser extends Equatable {
jobGroup: jobGroup ?? _jobGroup,
profile_img: profile_img ?? _profile_img,
);

int? get id => _id;

String get nickname => _nickname ?? '';

JobGroup? get jobGroup => _jobGroup;

String get profile_img => _profile_img ?? '';

Map<String, dynamic> toJson() {
Expand Down Expand Up @@ -85,6 +90,11 @@ class JobGroup {
_name = name;
}

JobGroup.fromJson(dynamic json) {
_id = json['id'] as int?;
_name = json['name'] as String?;
}

static List<JobGroup> fromJsonList(List<dynamic> jsonList) {
final result = <JobGroup>[];
for (final json in jsonList) {
Expand All @@ -93,12 +103,9 @@ class JobGroup {
return result;
}

JobGroup.fromJson(dynamic json) {
_id = json['id'] as int?;
_name = json['name'] as String?;
}
int? _id;
String? _name;

JobGroup copyWith({
int? id,
String? name,
Expand All @@ -107,7 +114,9 @@ class JobGroup {
id: id ?? _id,
name: name ?? _name,
);

int? get id => _id;

String? get name => _name;

Map<String, dynamic> toJson() {
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/api/user/profile_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ProfileApi {
final result = await _client.patchUri(
'/users/me',
body: {
'profile_img': profileImg
'profile_img': profileImg,
},
);
return result.when(
Expand Down
10 changes: 5 additions & 5 deletions lib/provider/kakao/kakao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import 'package:ac_project_app/cubits/profile/profile_info_cubit.dart';
import 'package:ac_project_app/cubits/profile/profile_state.dart';
import 'package:ac_project_app/di/set_up_get_it.dart';
import 'package:ac_project_app/models/folder/folder.dart';
import 'package:ac_project_app/models/link/link.dart' as MyLink;
import 'package:ac_project_app/models/link/link.dart' as my_link;
import 'package:ac_project_app/models/profile/profile.dart' as Profile;
import 'package:ac_project_app/models/profile/profile_image.dart';
import 'package:ac_project_app/provider/api/folders/link_api.dart';
import 'package:ac_project_app/provider/api/user/user_api.dart' as MyUserApi;
import 'package:ac_project_app/provider/api/user/user_api.dart' as my_user_api;
import 'package:ac_project_app/provider/login/firebase_auth_remote_data_source.dart';
import 'package:ac_project_app/routes.dart';
import 'package:ac_project_app/ui/widget/bottom_toast.dart';
Expand All @@ -22,7 +23,6 @@ import 'package:flutter/services.dart';
import 'package:kakao_flutter_sdk_share/kakao_flutter_sdk_share.dart';
import 'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:ac_project_app/models/profile/profile.dart' as Profile;

class Kakao {
static Future<bool> login() async {
Expand Down Expand Up @@ -94,7 +94,7 @@ class Kakao {
}
}

static Future<void> sendKakaoLinkShare(MyLink.Link link) async {
static Future<void> sendKakaoLinkShare(my_link.Link link) async {
final defaultFeed = FeedTemplate(
content: Content(
title: link.title ?? '',
Expand Down Expand Up @@ -248,7 +248,7 @@ class Kakao {
if (query.keys.contains('folderId')) {
final folderId = query['folderId']!;
final userId = query['userId'] ?? '';
getIt<MyUserApi.UserApi>().getUsersId(userId).then((result) {
getIt<my_user_api.UserApi>().getUsersId(userId).then((result) {
result.when(
success: (user) {
final profileInfoCubit = getIt<GetProfileInfoCubit>();
Expand Down
4 changes: 2 additions & 2 deletions lib/provider/share_data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ShareDataProvider {
'describe': item['comment'],
'image': item['image_link'],
'folder_name': item['folder_name'],
'created_at': item['created_at']
'created_at': item['created_at'],
});
}

Expand All @@ -57,7 +57,7 @@ class ShareDataProvider {
final folder = {
'name': json['name'],
'visible': json['visible'],
'created_at': json['created_at']
'created_at': json['created_at'],
};
result.add(folder);
}
Expand Down
10 changes: 7 additions & 3 deletions lib/ui/page/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class HomePage extends StatelessWidget {
child: NotificationListener<ScrollEndNotification>(
onNotification: (scrollNotification) {
final metrics = scrollNotification.metrics;
if (metrics.axisDirection != AxisDirection.down)
if (metrics.axisDirection != AxisDirection.down) {
return false;
}
if (metrics.extentAfter <= 800) {
context.read<LinksFromSelectedJobGroupCubit>().loadMore();
}
Expand All @@ -56,7 +57,10 @@ class HomePage extends StatelessWidget {
SliverToBoxAdapter(
child: Container(
margin: EdgeInsets.only(
left: 24.w, right: 24.w, top: 20.h),
left: 24.w,
right: 24.w,
top: 20.h,
),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
Expand Down Expand Up @@ -151,7 +155,7 @@ class HomePage extends StatelessWidget {
thickness: 1.w,
color: ccGrey200,
),
)
),
],
);
},
Expand Down
8 changes: 5 additions & 3 deletions lib/ui/page/my_folder/my_folder_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ class _MyFolderPageState extends State<MyFolderPage>
fontWeight: FontWeight.w500,
color: greyText,
),
)
),
],
)
),
],
),
if (isNotClassified)
Expand Down Expand Up @@ -495,7 +495,9 @@ class _MyFolderPageState extends State<MyFolderPage>

if (currFolder.visible ?? false) {
Kakao.sendFolderKakaoShare(
currFolder, profile);
currFolder,
profile,
);
} else {
showPopUp(
title: '폴더를 공개해 주세요',
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/view/links/link_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LinkDetailView extends StatelessWidget {
),
BlocProvider(
create: (_) => GetUserFoldersCubit(),
)
),
],
child: KeyboardDismissOnTap(
child: KeyboardVisibilityBuilder(
Expand Down Expand Up @@ -111,7 +111,6 @@ class LinkDetailView extends StatelessWidget {
bool linkVisible,
) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/view/links/my_link_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class MyLinkView extends StatelessWidget {
endIndent: 24.w,
),
),
)
),
],
);
},
Expand Down Expand Up @@ -657,7 +657,7 @@ class MyLinkView extends StatelessWidget {
),
),
),
)
),
],
),
);
Expand Down
12 changes: 7 additions & 5 deletions lib/ui/view/links/search_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,12 @@ class _SearchViewState extends State<SearchView> {
color: grey100,
child: CachedNetworkImage(
imageUrl: link.image ?? '',
fadeInDuration:
const Duration(milliseconds: 300),
fadeOutDuration:
const Duration(milliseconds: 300),
fadeInDuration: const Duration(
milliseconds: 300,
),
fadeOutDuration: const Duration(
milliseconds: 300,
),
imageBuilder:
(context, imageProvider) =>
Container(
Expand Down Expand Up @@ -443,7 +445,7 @@ class _SearchViewState extends State<SearchView> {
height: (18 / 14).h,
color: lightGrey700,
),
)
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/view/links/user_feed_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class UserFeedView extends StatelessWidget {
fontSize: 28.sp,
letterSpacing: -0.6.w,
),
)
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/view/profile/profile_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class _ProfileSelectorState extends State<ProfileSelector> {
'완료',
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16.sp),
),
)
),
],
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/view/report_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _ReportViewState extends State<ReportView> {
'완료',
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16.sp),
),
)
),
],
),
body: SingleChildScrollView(
Expand Down Expand Up @@ -228,7 +228,7 @@ class _ReportViewState extends State<ReportView> {
),
),
),
)
),
],
),
),
Expand Down Expand Up @@ -334,7 +334,7 @@ class _ReportViewState extends State<ReportView> {
fontSize: 14.sp,
fontWeight: FontWeight.w500,
),
)
),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/view/upload_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class _UploadViewState extends State<UploadView> with WidgetsBindingObserver {
child: LoadingWidget(),
)
else
const SizedBox.shrink()
const SizedBox.shrink(),
],
),
bottomSheet: buildBottomSheetButton(
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/view/user/email_login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ class _EmailLoginViewState extends State<EmailLoginView>
),
),
),
)
),
],
),
),
),
SizedBox(height: keyboardHeight)
SizedBox(height: keyboardHeight),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/view/user/sign_up_job_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class SignUpJobView extends StatelessWidget {
),
SizedBox(
height: 24.h,
)
),
],
),
);
Expand Down
Loading

0 comments on commit b50579e

Please sign in to comment.