Skip to content

Commit e6a5937

Browse files
committed
지도 개선
지도 개선
1 parent 2f43ea5 commit e6a5937

File tree

7 files changed

+191
-210
lines changed

7 files changed

+191
-210
lines changed

lib/common/login_text_form_field.dart

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class _LoginTextFormFieldState extends State<LoginTextFormField> {
5252
focusNode: widget.focusNode,
5353
onFieldSubmitted: widget.onSubmitted,
5454
onChanged: widget.onChanged,
55+
onTapOutside: (event) {
56+
// widget.focusNode.unfocus();
57+
FocusManager.instance.primaryFocus?.unfocus();
58+
},
5559
decoration: InputDecoration(
5660
helperText: widget.helperText,
5761
helperStyle: myTextStyle(

lib/common/my_text_field.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import 'my_text_style.dart';
88
class MyTextField extends StatefulWidget {
99
final TextEditingController controller;
1010
final FocusNode? focusNode;
11-
final bool autoFocus = true;
11+
final bool autoFocus;
1212
final void Function()? onTap;
1313
final void Function(PointerDownEvent event)? onTapOutside;
1414
final void Function(String value)? onSubmitted;
1515
final void Function(String value)? onChanged;
1616
final String? hintText;
1717

18-
MyTextField({
18+
const MyTextField({
1919
super.key,
2020
required this.controller,
2121
this.focusNode,
@@ -24,6 +24,7 @@ class MyTextField extends StatefulWidget {
2424
this.onSubmitted,
2525
this.onChanged,
2626
this.hintText,
27+
this.autoFocus = false,
2728
// this.hintText = ''
2829
});
2930

lib/common/single_child_scroll_fade_view.dart

+3
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ class SingleChildScrollFadeView extends StatefulWidget {
6262
this.topFadeHeight = 30,
6363
this.bottomFadeHeight = 30,
6464
this.child,
65+
this.physics,
6566
});
6667

6768
final ScrollController? scrollController;
6869
final double topFadeHeight;
6970
final double bottomFadeHeight;
7071
final Widget? child;
72+
final ScrollPhysics? physics;
7173

7274
@override
7375
State<SingleChildScrollFadeView> createState() =>
@@ -87,6 +89,7 @@ class _SingleChildScrollFadeViewState extends State<SingleChildScrollFadeView> {
8789
Widget build(BuildContext context) {
8890
return SingleChildScrollView(
8991
controller: _scrollController,
92+
physics: widget.physics,
9093
child: FadeShaderMask(
9194
scrollController: _scrollController!,
9295
topFadeHeight: widget.topFadeHeight,

lib/features/itinerary/screen.dart

+13-12
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ Future<BitmapDescriptor> svgToBitmapDescriptor(String assetName,
7777
ui.PlatformDispatcher.instance.views.first.devicePixelRatio;
7878

7979
//웹일 경우 픽셀 비율을 1로 설정
80-
var pixelRatio2 = kIsWeb ? 1.0 : pixelRatio;
80+
// var pixelRatio2 = kIsWeb ? 1.0 : pixelRatio;
8181

8282
return BitmapDescriptor.bytes(
83-
await svgAssetToPngBytes(assetName, pixelRatio2),
83+
await svgAssetToPngBytes(assetName, pixelRatio),
8484
imagePixelRatio: pixelRatio,
8585
);
8686
}
@@ -467,14 +467,15 @@ class _ItineraryEditorState extends State<ItineraryEditor>
467467
right: 0,
468468
left: 0,
469469
bottom: _bottomSheetHeight + 20,
470-
child: PointerInterceptor(
471-
child: Opacity(
472-
opacity: 0.7,
473-
child: Row(
474-
mainAxisAlignment: MainAxisAlignment.center,
475-
crossAxisAlignment: CrossAxisAlignment.start,
476-
children: [
477-
TextButton(
470+
child: Opacity(
471+
opacity: 0.7,
472+
child: Row(
473+
mainAxisAlignment: MainAxisAlignment.center,
474+
crossAxisAlignment: CrossAxisAlignment.start,
475+
mainAxisSize: MainAxisSize.min,
476+
children: [
477+
PointerInterceptor(
478+
child: TextButton(
478479
onPressed: () {
479480
setState(() {
480481
_globalGoogleMapCubit.update(
@@ -706,8 +707,8 @@ class _ItineraryEditorState extends State<ItineraryEditor>
706707
],
707708
),
708709
),
709-
],
710-
),
710+
),
711+
],
711712
),
712713
),
713714
),

lib/features/my_place/screen.dart

+122-87
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
77
import 'package:flutter_bloc/flutter_bloc.dart';
88
import 'package:google_maps_flutter/google_maps_flutter.dart';
99
import 'package:flutter_svg/svg.dart';
10+
import 'package:pointer_interceptor/pointer_interceptor.dart';
1011
import 'package:tradule/common/app_bar_blur.dart';
1112
import 'package:tradule/common/color.dart';
1213
import 'package:tradule/common/my_text_field.dart';
@@ -86,8 +87,10 @@ class _MyPlaceScreenState extends State<MyPlaceScreen>
8687
spacing: 20,
8788
children: <Widget>[
8889
MyTextField(
90+
key: Key('search'),
8991
controller: _searchController,
9092
hintText: '장소 이름, 태그로 검색',
93+
autoFocus: false,
9194
onSubmitted: (_) {
9295
// _searchPlace(_searchController.text);
9396
setState(() {});
@@ -96,6 +99,9 @@ class _MyPlaceScreenState extends State<MyPlaceScreen>
9699
// _searchPlace(value);
97100
setState(() {});
98101
},
102+
onTapOutside: (_) {
103+
FocusManager.instance.primaryFocus?.unfocus();
104+
},
99105
),
100106
Padding(
101107
padding: const EdgeInsets.only(top: 4),
@@ -353,6 +359,7 @@ class _AddMyPlaceDialogState extends State<AddMyPlaceDialog> {
353359
].toList();
354360
BitmapDescriptor _markerIcon = BitmapDescriptor.defaultMarker;
355361
LatLng _markerPosition = const LatLng(37.5662952, 126.9779451);
362+
bool scrollAble = true;
356363

357364
@override
358365
void initState() {
@@ -377,7 +384,8 @@ class _AddMyPlaceDialogState extends State<AddMyPlaceDialog> {
377384
final padding = MediaQuery.of(context).padding;
378385
return GestureDetector(
379386
onTap: () {
380-
FocusScope.of(context).unfocus();
387+
// FocusScope.of(context).unfocus();
388+
FocusManager.instance.primaryFocus?.unfocus();
381389
},
382390
child: Stack(
383391
children: [
@@ -390,26 +398,35 @@ class _AddMyPlaceDialogState extends State<AddMyPlaceDialog> {
390398
elevation: 0,
391399
color: Colors.transparent,
392400
child: Container(
393-
padding: const EdgeInsets.all(16),
401+
// padding: const EdgeInsets.all(16),
394402
decoration: BoxDecoration(
395403
color: Colors.white,
396404
borderRadius: BorderRadius.circular(16),
397405
),
398406
child: Column(
399407
spacing: 8,
400408
children: <Widget>[
401-
Text(
402-
'나만의 장소 추가',
403-
style: myTextStyle(
404-
color: cPrimaryDark,
405-
fontSize: 20,
406-
fontWeight: FontWeight.bold,
409+
Padding(
410+
padding:
411+
const EdgeInsets.only(top: 16, left: 16, right: 16),
412+
child: Text(
413+
'나만의 장소 추가',
414+
style: myTextStyle(
415+
color: cPrimaryDark,
416+
fontSize: 20,
417+
fontWeight: FontWeight.bold,
418+
),
407419
),
408420
),
409421
Expanded(
410422
child: SingleChildScrollFadeView(
423+
physics: scrollAble
424+
? const AlwaysScrollableScrollPhysics()
425+
: const NeverScrollableScrollPhysics(),
426+
scrollController: ScrollController(),
411427
child: Padding(
412-
padding: const EdgeInsets.all(8.0),
428+
padding: const EdgeInsets.all(8.0) +
429+
const EdgeInsets.symmetric(horizontal: 16),
413430
child: Column(
414431
spacing: 16,
415432
children: <Widget>[
@@ -464,60 +481,74 @@ class _AddMyPlaceDialogState extends State<AddMyPlaceDialog> {
464481
//구글 지도
465482
Padding(
466483
padding: const EdgeInsets.all(8.0),
467-
child: Column(
468-
children: [
469-
Stack(
470-
children: [
471-
Container(
472-
height: 300,
473-
child: GoogleMap(
474-
gestureRecognizers: {
475-
Factory<OneSequenceGestureRecognizer>(
476-
() =>
477-
EagerGestureRecognizer())
478-
},
479-
initialCameraPosition:
480-
const CameraPosition(
481-
target: LatLng(
482-
37.5662952, 126.9779451),
483-
zoom: 12,
484-
),
485-
markers: {
486-
Marker(
487-
markerId: const MarkerId('1'),
488-
position: const LatLng(
484+
child: MouseRegion(
485+
onEnter: (_) {
486+
setState(() {
487+
scrollAble = false;
488+
});
489+
},
490+
onExit: (_) {
491+
setState(() {
492+
scrollAble = true;
493+
});
494+
},
495+
child: Column(
496+
children: [
497+
Stack(
498+
children: [
499+
Container(
500+
height: 300,
501+
child: GoogleMap(
502+
webGestureHandling:
503+
WebGestureHandling.greedy,
504+
gestureRecognizers: const {
505+
Factory<OneSequenceGestureRecognizer>(
506+
EagerGestureRecognizer.new),
507+
},
508+
initialCameraPosition:
509+
const CameraPosition(
510+
target: LatLng(
489511
37.5662952, 126.9779451),
490-
icon: _markerIcon,
491-
draggable: true,
492-
onDrag: (LatLng latLng) {
493-
_markerPosition = latLng;
494-
setState(() {});
495-
},
512+
zoom: 12,
496513
),
497-
},
514+
markers: {
515+
Marker(
516+
markerId: const MarkerId('1'),
517+
position: const LatLng(
518+
37.5662952, 126.9779451),
519+
icon: _markerIcon,
520+
draggable: true,
521+
onDrag: (LatLng latLng) {
522+
_markerPosition = latLng;
523+
setState(() {});
524+
},
525+
),
526+
},
527+
),
498528
),
499-
),
500-
//장소 검색
501-
Positioned(
502-
top: 10,
503-
left: 10,
504-
right: 10,
505-
child: MyTextField(
506-
controller: TextEditingController(),
507-
hintText: '장소 검색',
529+
//장소 검색
530+
Positioned(
531+
top: 10,
532+
left: 10,
533+
right: 10,
534+
child: MyTextField(
535+
controller:
536+
TextEditingController(),
537+
hintText: '장소 검색',
538+
),
508539
),
540+
],
541+
),
542+
Text(
543+
'핀을 드래그하여 이동할 수 있어요!',
544+
style: myTextStyle(
545+
color: cPrimary,
546+
fontSize: 14,
509547
),
510-
],
511-
),
512-
Text(
513-
'핀을 드래그하여 이동할 수 있어요!',
514-
style: myTextStyle(
515-
color: cPrimary,
516-
fontSize: 14,
548+
textAlign: TextAlign.center,
517549
),
518-
textAlign: TextAlign.center,
519-
),
520-
],
550+
],
551+
),
521552
),
522553
),
523554

@@ -565,36 +596,40 @@ class _AddMyPlaceDialogState extends State<AddMyPlaceDialog> {
565596
),
566597
),
567598
),
568-
Row(
569-
mainAxisAlignment: MainAxisAlignment.end,
570-
children: <Widget>[
571-
ElevatedButton(
572-
onPressed: () {
573-
Navigator.pop(context);
574-
},
575-
child: const Text('취소'),
576-
),
577-
const SizedBox(width: 8),
578-
ElevatedButton(
579-
onPressed: () {
580-
final placeData = PlaceData(
581-
id: Random().nextInt(1000000),
582-
title: _titleController.text,
583-
description: _descriptionController.text,
584-
latitude: _markerPosition.latitude,
585-
longitude: _markerPosition.longitude,
586-
address: '주소 없음',
587-
tags: _tags,
588-
isProvided: false,
589-
createdTime: DateTime.now(),
590-
);
591-
ServerWrapper.userCubit.addPlace(placeData);
592-
ServerWrapper.putMyPlaceList();
593-
Navigator.pop(context);
594-
},
595-
child: const Text('추가'),
596-
),
597-
],
599+
Padding(
600+
padding: const EdgeInsets.only(
601+
bottom: 16, left: 16, right: 16),
602+
child: Row(
603+
mainAxisAlignment: MainAxisAlignment.end,
604+
children: <Widget>[
605+
ElevatedButton(
606+
onPressed: () {
607+
Navigator.pop(context);
608+
},
609+
child: const Text('취소'),
610+
),
611+
const SizedBox(width: 8),
612+
ElevatedButton(
613+
onPressed: () {
614+
final placeData = PlaceData(
615+
id: Random().nextInt(1000000),
616+
title: _titleController.text,
617+
description: _descriptionController.text,
618+
latitude: _markerPosition.latitude,
619+
longitude: _markerPosition.longitude,
620+
address: '주소 없음',
621+
tags: _tags,
622+
isProvided: false,
623+
createdTime: DateTime.now(),
624+
);
625+
ServerWrapper.userCubit.addPlace(placeData);
626+
ServerWrapper.putMyPlaceList();
627+
Navigator.pop(context);
628+
},
629+
child: const Text('추가'),
630+
),
631+
],
632+
),
598633
),
599634
],
600635
),

0 commit comments

Comments
 (0)