Skip to content

Commit

Permalink
♻️Refactor: #53 profile folder structer
Browse files Browse the repository at this point in the history
  • Loading branch information
seochan99 committed Apr 7, 2024
1 parent 1d06625 commit bea23b1
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 79 deletions.
2 changes: 1 addition & 1 deletion lib/utilities/style/font_system.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';

class FontStyles {
class FontSystem {
static const TextStyle semiBold24 = TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.w600,
Expand Down
2 changes: 1 addition & 1 deletion lib/views/auth/auth_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:earlips/services/auth/auth_service.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

/// [authDialog] is a function that shows a dialog to confirm the user's authentication.
Future<void> authDialog({
required BuildContext context,
required String title,
Expand All @@ -18,7 +19,6 @@ Future<void> authDialog({
textCancel: textCancel,
onCancel: () => Get.back(),
onConfirm: () async {
/// title == '로그아웃' ? 로그아웃 : 회원탈퇴
title == 'profile_account_logout'.tr
? await authService.signOut()
: await authService.withdraw();
Expand Down
64 changes: 36 additions & 28 deletions lib/views/profile/profile_account/profile_account_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@ import 'package:earlips/views/base/default_back_appbar.dart';
import 'package:flutter/material.dart';
import 'package:get/get_utils/src/extensions/internacionalization.dart';

/// [ProfileAccountScreen] is a screen that allows the user to log out or sign out.
class ProfileAccountScreen extends StatelessWidget {
const ProfileAccountScreen({super.key});

/// [buildListTile] is a function that creates a ListTile.
Widget buildListTile(BuildContext context, String title, String alertTitle,
String alertContent, String confirmText, String cancelText) {
return ListTile(
contentPadding: EdgeInsets.zero,
title: Text(
title.tr,
style: const TextStyle(fontSize: 16, color: Color(0xff151515)),
),
onTap: () {
authDialog(
context: context,
title: alertTitle.tr,
content: alertContent.tr,
textConfirm: confirmText.tr,
textCancel: cancelText.tr,
);
},
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -23,35 +45,21 @@ class ProfileAccountScreen extends StatelessWidget {
padding: const EdgeInsets.all(20.0),
child: Column(
children: [
ListTile(
contentPadding: EdgeInsets.zero,
title: Text('profile_account_logout'.tr,
style: const TextStyle(
fontSize: 16, color: Color(0xff151515))),
onTap: () {
authDialog(
context: context,
title: 'profile_account_logout_alert_title'.tr,
content: 'profile_account_logout_alert_content'.tr,
textConfirm: 'profile_account_logout_alert_title'.tr,
textCancel: 'profile_account_logout_alert_cancel'.tr,
);
},
buildListTile(
context,
'profile_account_logout',
'profile_account_logout_alert_title',
'profile_account_logout_alert_content',
'profile_account_logout_alert_title',
'profile_account_logout_alert_cancel',
),
ListTile(
contentPadding: EdgeInsets.zero,
title: Text('profile_account_signout'.tr,
style: const TextStyle(
fontSize: 16, color: Color(0xff151515))),
onTap: () {
authDialog(
context: context,
title: 'profile_account_signout'.tr,
content: 'profile_account_signout_alert_content'.tr,
textConfirm: 'profile_account_signout_alert_confirm'.tr,
textCancel: 'profile_account_signout_alert_cancel'.tr,
);
},
buildListTile(
context,
'profile_account_signout',
'profile_account_signout',
'profile_account_signout_alert_content',
'profile_account_signout_alert_confirm',
'profile_account_signout_alert_cancel',
),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:earlips/utilities/style/color_system.dart';
import 'package:earlips/utilities/style/font_system.dart';
import 'package:earlips/viewModels/user/user_viewmodel.dart';
import 'package:earlips/views/base/default_back_appbar.dart';
import 'package:flutter/material.dart';
Expand All @@ -22,45 +23,41 @@ class ProfileLanguageScreen extends StatelessWidget {
body: Container(
width: double.infinity,
color: ColorSystem.white,
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildLanguageSettingSection(
title: 'language_setting_system'.tr,
selectedLanguage: userViewModel.systemLanguage,
onLanguageSelected: (value) {
userViewModel.systemLanguage.value = value!;
userViewModel.updateLanguageSettings(value);
},
languageOptions: [
DropdownMenuItem(value: '한국어', child: Text('korean'.tr)),
DropdownMenuItem(value: 'English', child: Text('english'.tr)),
],
),
const SizedBox(height: 20),
_buildLanguageSettingSection(
title: 'language_setting_learning'.tr,
selectedLanguage: userViewModel.learningLanguage,
onLanguageSelected: (value) {
userViewModel.learningLanguage.value = value!;
userViewModel.updateLanguageSettings(value);
},
languageOptions: [
DropdownMenuItem(value: '한국어', child: Text('korean'.tr)),
DropdownMenuItem(value: 'English', child: Text('english'.tr)),
],
),
],
),
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildLanguageSettingSection(
title: 'language_setting_system'.tr,
selectedLanguage: userViewModel.systemLanguage,
onLanguageSelected: (value) {
userViewModel.systemLanguage.value = value!;
userViewModel.updateLanguageSettings(value);
},
languageOptions: [
DropdownMenuItem(value: '한국어', child: Text('korean'.tr)),
DropdownMenuItem(value: 'English', child: Text('english'.tr)),
],
),
const SizedBox(height: 20),
_buildLanguageSettingSection(
title: 'language_setting_learning'.tr,
selectedLanguage: userViewModel.learningLanguage,
onLanguageSelected: (value) {
userViewModel.learningLanguage.value = value!;
userViewModel.updateLanguageSettings(value);
},
languageOptions: [
DropdownMenuItem(value: '한국어', child: Text('korean'.tr)),
DropdownMenuItem(value: 'English', child: Text('english'.tr)),
],
),
],
),
),
);
}

// 셋팅 섹션 위젯
// 셋팅 섹션 위젯
Widget _buildLanguageSettingSection({
required String title,
required RxString selectedLanguage,
Expand All @@ -70,17 +67,24 @@ class ProfileLanguageScreen extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w500)),
Text(
title,
style: FontSystem.medium20.copyWith(color: ColorSystem.black),
),
const SizedBox(height: 10),
Obx(() => DropdownButton<String>(
value: selectedLanguage.value,
items: languageOptions,
onChanged: (newValue) {
onLanguageSelected(newValue);
},
hint: Text('select_language'.tr),
)),
Obx(
() => DropdownButton<String>(
value: selectedLanguage.value,
items: languageOptions,
onChanged: (newValue) {
onLanguageSelected(newValue);
},
hint: Text(
'select_language'.tr,
style: FontSystem.regular12.copyWith(color: ColorSystem.black),
),
),
),
],
);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/views/profile/profile_screen.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:earlips/utilities/style/color_system.dart';
import 'package:earlips/views/profile/profile_divider_widget.dart';
import 'package:earlips/views/profile/profile_header_widget.dart';
import 'package:earlips/views/profile/profile_setting_row_btn_widget.dart';
import 'package:earlips/views/profile/profile_setting_row_box_widget.dart';
import 'package:earlips/views/profile/widget/profile_divider_widget.dart';
import 'package:earlips/views/profile/widget/profile_header_widget.dart';
import 'package:earlips/views/profile/widget/profile_setting_row_btn_widget.dart';
import 'package:earlips/views/profile/widget/profile_setting_row_box_widget.dart';
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get_utils/src/extensions/internacionalization.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/views/root/root_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:earlips/views/home/home_screen.dart';
import 'package:earlips/views/root/custom_bottom_navigation_bar.dart';
import '../../utilities/app_routes.dart';
import '../../viewModels/root/root_viewmodel.dart';
import '../base/base_screen.dart';
import 'package:flutter_svg/flutter_svg.dart';
Expand Down

0 comments on commit bea23b1

Please sign in to comment.