Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

릴리즈용 리팩토링 ( 안드로이드 테스트 완료 ) #6

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions assets/images/phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/images/safehouse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions assets/logo/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/voice/voice_1.mp3
Binary file not shown.
Binary file added assets/voice/voice_2.mp3
Binary file not shown.
Binary file added assets/voice/voice_3.mp3
Binary file not shown.
Binary file added assets/voice/voice_4.mp3
Binary file not shown.
57 changes: 57 additions & 0 deletions lib/core/CustomDialogs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// custom_dialogs.dart
import 'package:flutter/material.dart';

class CustomDialogs {
// 일반 다이얼로그 생성
static void showCustomDialog(
BuildContext context, {
required String title,
required String content,
String? confirmText = '확인',
String? cancelText = '취소',
VoidCallback? onConfirm,
VoidCallback? onCancel,
bool isTextField = false,
}) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: isTextField
? Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(content),
TextField(
keyboardType: TextInputType.number,
decoration: const InputDecoration(
labelText: '시간(분)',
),
),
],
)
: Text(content),
actions: [
if (onCancel != null)
TextButton(
onPressed: () {
onCancel();
Navigator.of(context).pop();
},
child: Text(cancelText!),
),
if (onConfirm != null)
ElevatedButton(
onPressed: () {
onConfirm();
Navigator.of(context).pop();
},
child: Text(confirmText!),
),
],
);
},
);
}
}
10 changes: 9 additions & 1 deletion lib/core/SplashScreen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:blueberry_flutter_template/feature/onboarding/OnboardingScreen.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'TopScreen.dart';

Expand All @@ -28,6 +30,9 @@ class _SplashScreenState extends ConsumerState<SplashScreen> {

/// 앱 초기화를 단계별로 수행하는 함수
Future<void> _initializeApp() async {
final prefs = await SharedPreferences.getInstance();
final hasSeenOnboarding = prefs.getBool('hasSeenOnboarding') ?? false;

try {
// 단계별로 로딩 상태를 업데이트
// 단계별 로딩은 사용하지 않음.
Expand All @@ -39,7 +44,10 @@ class _SplashScreenState extends ConsumerState<SplashScreen> {
await Future.delayed(const Duration(seconds: 3));
// 초기화 완료 후 메인 화면으로 전환
if (mounted) {
context.goNamed(TopScreen.name);
hasSeenOnboarding
? context.goNamed(OnboardingScreen.name) // 온보딩 화면을 본 경우
: context.goNamed(OnboardingScreen.name) // 온보딩 화면을 보지 않은 경우
;
}
} catch (e) {
// 초기화 중 발생한 오류 처리
Expand Down
56 changes: 28 additions & 28 deletions lib/feature/map/PoliceMapScreen.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'dart:async';

import 'package:blueberry_flutter_template/feature/map/provider/LocationProvider.dart';
import 'package:blueberry_flutter_template/feature/map/provider/PermissionProvider.dart';
import 'package:blueberry_flutter_template/feature/map/provider/PoliceStationProvider.dart';
import 'package:blueberry_flutter_template/feature/map/widget/GoogleMapWidget.dart';
import 'package:blueberry_flutter_template/feature/map/widget/PermissionDeniedWidget.dart';
import 'package:blueberry_flutter_template/feature/map/widget/PoliceStationListWidget.dart';
import 'package:blueberry_flutter_template/feature/map/widget/SendMessageWidget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -47,38 +45,40 @@ class _PoliceMapScreenState extends ConsumerState<PoliceMapScreen> {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: policeStationsAsyncValue.when(
data: (policeStations) => GoogleMapWidget(
googleMapControllerCompleter:
_googleMapControllerCompleter,
locationState: locationState,
policeStationsAsyncValue: policeStationsAsyncValue,
),
loading: () =>
const Center(child: CircularProgressIndicator()),
error: (error, stack) =>
Center(child: Text('Error: $error')),
),
),
// Expanded(
// child: policeStationsAsyncValue.when(
// data: (policeStations) => GoogleMapWidget(
// googleMapControllerCompleter:
// _googleMapControllerCompleter,
// locationState: locationState,
// policeStationsAsyncValue: policeStationsAsyncValue,
// ),
// loading: () =>
// const Center(child: CircularProgressIndicator()),
// error: (error, stack) =>
// Center(child: Text('Error: $error')),
// ),
// ),
const SizedBox(height: 8),
Expanded(
child: PoliceStationListWidget(
googleMapControllerCompleter:
_googleMapControllerCompleter,
locationState: locationState,
policeStationsAsyncValue: policeStationsAsyncValue,
),
),
SendMessage(locationState: locationState),
// Expanded(
// child: PoliceStationListWidget(
// googleMapControllerCompleter:
// _googleMapControllerCompleter,
// locationState: locationState,
// policeStationsAsyncValue: policeStationsAsyncValue,
// ),
// ),
Center(child: SendMessage(locationState: locationState)),
],
),
),
);
} else {
return PermissionDeniedWidget(permissionStatus: permissionStatus);
}
// else {
// return PermissionDeniedWidget(permissionStatus: permissionStatus);
// }
}(),
);
}
Expand Down
39 changes: 26 additions & 13 deletions lib/feature/mypage/MyPageScreen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:blueberry_flutter_template/core/CustomDialogs.dart';
import 'package:flutter/material.dart';

class MyPageScreen extends StatelessWidget {
Expand All @@ -8,41 +9,53 @@ class MyPageScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('마이페이지'),
centerTitle: true,
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
"nickname",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 40.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('주변 범죄 위험도 확인'),
),
const SizedBox(height: 16.0),
ElevatedButton(
onPressed: () {
// 자동 대화 시간 설정 버튼의 기능 구현
CustomDialogs.showCustomDialog(
context,
title: '발송 문자 지정',
content: '구현 예정입니다.',
onConfirm: () {
// 발송 문자 선택 로직 구현
},
);
},
child: const Text('자동 대화 시간 설정'),
),
Expand Down
7 changes: 5 additions & 2 deletions lib/feature/onboarding/OnboardingScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import 'package:blueberry_flutter_template/core/TopScreen.dart';
import 'package:blueberry_flutter_template/feature/onboarding/widgets/OnboardingPageViewBuilder.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'OnboardingData.dart';
import 'widgets/OnboardingDotWidget.dart';
import 'widgets/OnboardingPageButton.dart';

class OnboardingScreen extends StatefulWidget {
static const String name = '/onboarding';
static const String name = 'OnboardingScreen';

const OnboardingScreen({super.key});

Expand Down Expand Up @@ -38,8 +39,10 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
});
}

void _onNextPressed() {
void _onNextPressed() async {
if (_currentPage == OnboardingData.pageDataList.length - 1) {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('hasSeenOnboarding', true);
context.goNamed(TopScreen.name);
} else {
_pageController.nextPage(
Expand Down
14 changes: 11 additions & 3 deletions lib/feature/voiceOutput/widget/VoiceOutputWidget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:audioplayers/audioplayers.dart';
import 'package:blueberry_flutter_template/gen/assets.gen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../provider/VoiceOutputProvider.dart';

class VoiceOutputWidget extends ConsumerWidget {
Expand Down Expand Up @@ -27,7 +30,7 @@ class VoiceOutputWidget extends ConsumerWidget {
children: data
.map((text) => Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: VoiceOutputRow(text: text),
child: VoiceOutputRow(text: text, index: data.indexOf(text)),
))
.toList(),
),
Expand All @@ -37,8 +40,10 @@ class VoiceOutputWidget extends ConsumerWidget {

class VoiceOutputRow extends StatelessWidget {
final String text;
final int index;
final player = AudioPlayer();

const VoiceOutputRow({super.key, required this.text});
VoiceOutputRow({super.key, required this.text, required this.index});

@override
Widget build(BuildContext context) {
Expand All @@ -56,7 +61,10 @@ class VoiceOutputRow extends StatelessWidget {
),
const SizedBox(width: 8),
ElevatedButton(
onPressed: () {},
onPressed: () {
final source = AssetSource("voice/voice_${index+1}.mp3");
player.play(source);
},
child: const Text("button"),
),
],
Expand Down
Loading
Loading