From 94277dc3d35cd09372de30883607836568268735 Mon Sep 17 00:00:00 2001 From: Jungwoo <108061510+jwson-automation@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:56:53 +0900 Subject: [PATCH] add setting screen (#14) --- lib/core/TopScreen.dart | 58 +++++++++---------- lib/feature/mypage/MyPageScreen.dart | 67 ---------------------- lib/feature/setting/SettingScreen.dart | 77 ++++++++++++++++++++++++++ lib/services/FirestoreService.dart | 2 +- lib/utils/AppStrings.dart | 4 +- lib/utils/DialogHelpers.dart | 4 +- 6 files changed, 112 insertions(+), 100 deletions(-) delete mode 100644 lib/feature/mypage/MyPageScreen.dart create mode 100644 lib/feature/setting/SettingScreen.dart diff --git a/lib/core/TopScreen.dart b/lib/core/TopScreen.dart index 51bf9d3..8c390c8 100644 --- a/lib/core/TopScreen.dart +++ b/lib/core/TopScreen.dart @@ -1,6 +1,5 @@ -import 'package:blueberry_flutter_template/feature/map/PoliceMapScreen.dart'; -import 'package:blueberry_flutter_template/feature/mypage/MyPageScreen.dart'; import 'package:blueberry_flutter_template/feature/send/SendMessageScreen.dart'; +import 'package:blueberry_flutter_template/feature/setting/SettingScreen.dart'; import 'package:blueberry_flutter_template/feature/voiceOutput/VoiceOutputScreen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -26,7 +25,7 @@ class TopScreen extends ConsumerWidget { final List pages = [ const VoiceOutputScreen(), const SendMessageScreen(), - const MyPageScreen(), + const SettingScreen(), ]; return Scaffold( @@ -67,36 +66,37 @@ class CustomBottomNavigationBar extends StatelessWidget { return Material( color: Colors.transparent, child: InkWell( - onTap: () => onPageChanged(index), - customBorder: const CircleBorder(), - child: Container( - width: 100, - height: 100, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 30, - height: 30, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: index == currentIndex ? Colors.blue : Colors.grey, - ), - ), - const SizedBox(height: 3,), - if (index == currentIndex) + onTap: () => onPageChanged(index), + customBorder: const CircleBorder(), + child: Container( + width: 100, + height: 100, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ Container( - width: 20, - height: 6, + width: 30, + height: 30, decoration: BoxDecoration( - color: Colors.blue, - borderRadius: BorderRadius.circular(10) + shape: BoxShape.circle, + color: + index == currentIndex ? Colors.blue : Colors.grey, ), ), - ], - ), - ) - ), + const SizedBox( + height: 3, + ), + if (index == currentIndex) + Container( + width: 20, + height: 6, + decoration: BoxDecoration( + color: Colors.blue, + borderRadius: BorderRadius.circular(10)), + ), + ], + ), + )), ); }), ), diff --git a/lib/feature/mypage/MyPageScreen.dart b/lib/feature/mypage/MyPageScreen.dart deleted file mode 100644 index 6b71b6a..0000000 --- a/lib/feature/mypage/MyPageScreen.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'package:blueberry_flutter_template/core/CustomDialogs.dart'; -import 'package:flutter/material.dart'; - -class MyPageScreen extends StatelessWidget { - static const name = 'MyPageScreen'; - - const MyPageScreen({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - ElevatedButton( - onPressed: () { - // 발송 문자 지정 버튼의 기능 구현 - CustomDialogs.showCustomDialog( - context, - title: '발송 문자 지정', - content: '구현 예정입니다.', - onConfirm: () { - // 발송 문자 선택 로직 구현 - }, - ); - }, - child: const Text('발송 문자 지정'), - ), - const SizedBox(height: 16.0), - ElevatedButton( - onPressed: () { - // 주변 범죄 위험도 확인 버튼의 기능 구현 - CustomDialogs.showCustomDialog( - context, - title: '발송 문자 지정', - content: '구현 예정입니다.', - onConfirm: () { - // 발송 문자 선택 로직 구현 - }, - ); - }, - child: const Text('주변 범죄 위험도 확인'), - ), - const SizedBox(height: 16.0), - ElevatedButton( - onPressed: () { - // 자동 대화 시간 설정 버튼의 기능 구현 - CustomDialogs.showCustomDialog( - context, - title: '발송 문자 지정', - content: '구현 예정입니다.', - onConfirm: () { - // 발송 문자 선택 로직 구현 - }, - ); - }, - child: const Text('자동 대화 시간 설정'), - ), - ], - ), - ), - ); - } -} diff --git a/lib/feature/setting/SettingScreen.dart b/lib/feature/setting/SettingScreen.dart new file mode 100644 index 0000000..a0ced00 --- /dev/null +++ b/lib/feature/setting/SettingScreen.dart @@ -0,0 +1,77 @@ +import 'package:blueberry_flutter_template/utils/DialogHelpers.dart'; +import 'package:flutter/material.dart'; + +class SettingScreen extends StatelessWidget { + static const name = 'MyPageScreen'; + + const SettingScreen({super.key}); + + @override + Widget build(BuildContext context) { + // _settings 리스트 초기화 + final List> settingData = [ + { + 'title': '주변 경찰서 위치 확인하기', + 'icon': Icons.location_on, + 'onTap': () { + // 프로필 수정 화면으로 이동하는 코드 + showErrorDialog(context, '아직 준비중인 기능입니다.'); + }, + }, + { + 'title': '경찰 순찰 빈도 및 일정', + 'icon': Icons.person, + 'onTap': () { + // 알림 설정 화면으로 이동하는 코드 + showErrorDialog(context, '아직 준비중인 기능입니다.'); + }, + }, + { + 'title': '여성 안심 귀가 서비스', + 'icon': Icons.safety_check, + 'onTap': () { + // 계정 관리 화면으로 이동하는 코드 + showErrorDialog(context, '아직 준비중인 기능입니다.'); + }, + }, + // 더 많은 설정 항목 추가 가능 + ]; + + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: ListView.builder( + shrinkWrap: true, + itemCount: settingData.length, + itemBuilder: (context, index) { + return ListTile( + title: SettingListTile(context, settingData[index]['title'], + settingData[index]['onTap'], settingData[index]['icon']), + ); + }), + ), + )); + } +} + +Widget SettingListTile( + BuildContext, String title, Function onTap, IconData icon) { + return Padding( + padding: const EdgeInsets.fromLTRB(0, 20.0, 0, 0), + child: Container( + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10.0), + ), + child: ListTile( + leading: Icon(icon, color: Colors.black, size: 40.0), + title: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16.0), + child: Text(title, style: const TextStyle(fontSize: 20.0)), + ), + onTap: () => onTap(), + ), + ), + ); +} diff --git a/lib/services/FirestoreService.dart b/lib/services/FirestoreService.dart index 8b6fe81..17915be 100644 --- a/lib/services/FirestoreService.dart +++ b/lib/services/FirestoreService.dart @@ -53,7 +53,7 @@ class FirestoreService { .doc(userId) .set({'imageUrl': imageUrl}); } catch (e) { - throw Exception('Failed to create mypage image: $e'); + throw Exception('Failed to create setting image: $e'); } } } diff --git a/lib/utils/AppStrings.dart b/lib/utils/AppStrings.dart index a636d1d..45a6d53 100644 --- a/lib/utils/AppStrings.dart +++ b/lib/utils/AppStrings.dart @@ -18,13 +18,15 @@ class AppStrings { static const String nickNameTextWidgetdefaultNickName = '닉네임'; static const String nickNameTextWidgetError = '오류'; - //MyPageScreen.dart + //SettingScreen.dart static const String myPageTitle = '내 페이지'; static const String loginButtonText = '로그인'; static const String logoutButtonText = '로그아웃'; static const String welcomeBackText = '다시 오신 것을 환영합니다!'; static const String signUpButtonText = '회원가입'; static const String errorTitle = '오류'; + static const String showSuccessDialogTitle = '성공'; + static const String showErrorDialogTitle = '오류'; static const String okButtonText = '확인'; static const String loggedInMessage = '로그인 되었습니다.'; static const String passwordForgot = '비밀번호를 잊어버렸나요?'; diff --git a/lib/utils/DialogHelpers.dart b/lib/utils/DialogHelpers.dart index 074ee2a..994c6df 100644 --- a/lib/utils/DialogHelpers.dart +++ b/lib/utils/DialogHelpers.dart @@ -7,7 +7,7 @@ void showSuccessDialog(BuildContext context, String message) { context: context, builder: (BuildContext context) { return AlertDialog( - title: const Text(AppStrings.okButtonText), + title: const Text(AppStrings.showSuccessDialogTitle), content: Text(message), actions: [ TextButton( @@ -27,7 +27,7 @@ void showErrorDialog(BuildContext context, String message) { context: context, builder: (BuildContext context) { return AlertDialog( - title: const Text(AppStrings.errorTitle), + title: const Text(AppStrings.showErrorDialogTitle), content: Text(message), actions: [ TextButton(