generated from blueberry-team/blueberry_template_deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad44d80
commit b763054
Showing
8 changed files
with
259 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,85 @@ | ||
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/SendMessageWidget.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:google_maps_flutter/google_maps_flutter.dart'; | ||
|
||
class PoliceMapScreen extends ConsumerStatefulWidget { | ||
const PoliceMapScreen({super.key}); | ||
|
||
@override | ||
_PoliceMapScreenState createState() => _PoliceMapScreenState(); | ||
} | ||
|
||
class _PoliceMapScreenState extends ConsumerState<PoliceMapScreen> { | ||
final Completer<GoogleMapController> _googleMapControllerCompleter = | ||
Completer<GoogleMapController>(); | ||
|
||
@override | ||
void didChangeDependencies() { | ||
super.didChangeDependencies(); | ||
_checkPermission(); | ||
} | ||
|
||
Future<void> _checkPermission() async { | ||
await ref.read(permissionProvider.notifier).checkPermission(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final permissionStatus = ref.watch(permissionProvider); | ||
final locationState = ref.watch(locationProvider); | ||
final policeStationsAsyncValue = | ||
ref.watch(policeStationsProvider(locationState)); | ||
|
||
return Scaffold( | ||
body: () { | ||
if (permissionStatus == LocationPermissionStatus.initial) { | ||
return const Center(child: CircularProgressIndicator()); | ||
} else if (permissionStatus == LocationPermissionStatus.granted) { | ||
return SafeArea( | ||
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')), | ||
// ), | ||
// ), | ||
const SizedBox(height: 8), | ||
// Expanded( | ||
// child: PoliceStationListWidget( | ||
// googleMapControllerCompleter: | ||
// _googleMapControllerCompleter, | ||
// locationState: locationState, | ||
// policeStationsAsyncValue: policeStationsAsyncValue, | ||
// ), | ||
// ), | ||
Center(child: SendMessage(locationState: locationState)), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
// else { | ||
// return PermissionDeniedWidget(permissionStatus: permissionStatus); | ||
// } | ||
}(), | ||
); | ||
} | ||
} | ||
// 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/PoliceStationListWidget.dart'; | ||
// import 'package:flutter/material.dart'; | ||
// import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
// import 'package:google_maps_flutter/google_maps_flutter.dart'; | ||
// | ||
// class PoliceMapScreen extends ConsumerStatefulWidget { | ||
// const PoliceMapScreen({super.key}); | ||
// | ||
// @override | ||
// _PoliceMapScreenState createState() => _PoliceMapScreenState(); | ||
// } | ||
// | ||
// class _PoliceMapScreenState extends ConsumerState<PoliceMapScreen> { | ||
// final Completer<GoogleMapController> _googleMapControllerCompleter = | ||
// Completer<GoogleMapController>(); | ||
// | ||
// @override | ||
// void didChangeDependencies() { | ||
// super.didChangeDependencies(); | ||
// _checkPermission(); | ||
// } | ||
// | ||
// Future<void> _checkPermission() async { | ||
// await ref.read(permissionProvider.notifier).checkPermission(); | ||
// } | ||
// | ||
// @override | ||
// Widget build(BuildContext context) { | ||
// final permissionStatus = ref.watch(permissionProvider); | ||
// final locationState = ref.watch(locationProvider); | ||
// final policeStationsAsyncValue = | ||
// ref.watch(policeStationsProvider(locationState)); | ||
// | ||
// return Scaffold( | ||
// body: () { | ||
// if (permissionStatus == LocationPermissionStatus.initial) { | ||
// return const Center(child: CircularProgressIndicator()); | ||
// } else if (permissionStatus == LocationPermissionStatus.granted) { | ||
// return SafeArea( | ||
// 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')), | ||
// ), | ||
// ), | ||
// const SizedBox(height: 8), | ||
// Expanded( | ||
// child: PoliceStationListWidget( | ||
// googleMapControllerCompleter: | ||
// _googleMapControllerCompleter, | ||
// locationState: locationState, | ||
// policeStationsAsyncValue: policeStationsAsyncValue, | ||
// ), | ||
// ), | ||
// ], | ||
// ), | ||
// ), | ||
// ); | ||
// } | ||
// // else { | ||
// // return PermissionDeniedWidget(permissionStatus: permissionStatus); | ||
// // } | ||
// }(), | ||
// ); | ||
// } | ||
// } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:blueberry_flutter_template/feature/send/widget/SendMessageButton.dart'; | ||
import 'package:blueberry_flutter_template/feature/send/widget/SendMessagePreview.dart'; | ||
import 'package:blueberry_flutter_template/feature/send/widget/SendMessagePreviewChangeButton.dart'; | ||
import 'package:blueberry_flutter_template/utils/AppTextStyle.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class SendMessageScreen extends StatelessWidget { | ||
const SendMessageScreen({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(), | ||
body: const Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Expanded(flex: 1, child: SendMessageTitleText()), | ||
Expanded(flex: 4, child: SendMessagePreview()), | ||
Expanded(flex: 1, child: SendMessagePreviewChangeButton()), | ||
Expanded( | ||
flex: 5, | ||
child: SendMessageButton(), | ||
) | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class SendMessageTitleText extends StatelessWidget { | ||
const SendMessageTitleText({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Text( | ||
'경찰서에 문자하기', | ||
style: black24TextStyle, | ||
); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
class MessageIndexNotifier extends StateNotifier<int> { | ||
MessageIndexNotifier() : super(0); | ||
|
||
void changeIndex() { | ||
state = (state + 1) % messages.length; | ||
} | ||
} | ||
|
||
final messageIndexProvider = | ||
StateNotifierProvider<MessageIndexNotifier, int>((ref) { | ||
return MessageIndexNotifier(); | ||
}); | ||
|
||
final messages = [ | ||
'이상한 사람이\n따라오고 있어요.\n도와주세요.', | ||
'수상한 사람이 있어요 \n도와주세요.', | ||
'취해서 난동을 부리는 사람이 있어요 \n도와주세요.' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:blueberry_flutter_template/feature/send/provider/messageIndexProvider.dart'; | ||
import 'package:blueberry_flutter_template/utils/AppStrings.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
|
||
class SendMessageButton extends ConsumerWidget { | ||
const SendMessageButton({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final index = ref.watch(messageIndexProvider); | ||
return CircleAvatar( | ||
backgroundColor: Colors.black, | ||
radius: 50, | ||
child: IconButton( | ||
onPressed: () async { | ||
final Uri smsUri = Uri( | ||
scheme: 'sms', | ||
path: '112', | ||
queryParameters: <String, String>{ | ||
'body': messages[index], | ||
}, | ||
); | ||
|
||
if (await canLaunchUrl(smsUri)) { | ||
await launchUrl(smsUri); | ||
} else { | ||
showDialog( | ||
context: context, | ||
builder: (BuildContext context) { | ||
return const AlertDialog( | ||
content: Text(AppStrings.errorMessage_sendFailed), | ||
); | ||
}, | ||
); | ||
} | ||
}, | ||
icon: const Icon(Icons.send), | ||
// 마이크 아이콘 | ||
iconSize: 50, | ||
// 아이콘 크기 | ||
color: Colors.white, | ||
// 아이콘 색상 | ||
splashRadius: 30, // 클릭 반경 | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:blueberry_flutter_template/feature/send/provider/messageIndexProvider.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
class SendMessagePreview extends ConsumerWidget { | ||
const SendMessagePreview({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final index = ref.watch(messageIndexProvider); | ||
final notifier = ref.watch(messageIndexProvider.notifier); | ||
// 카테고리 데이터를 리스트로 정의 | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 60.0), | ||
child: Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Text( | ||
messages[index], | ||
textAlign: TextAlign.center, | ||
style: TextStyle( | ||
fontSize: 32.0, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
SizedBox(height: 60), | ||
|
||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.