Repository navigation
feat: 지도 페이지 퍼블리싱 #13
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
59c3863
chore: add kakao map and geolocator setup
leejia324 6e9e85c
feat: add expandable map floating action button
leejia324 4a3a9cf
feat: build map page with kakao map and current location
leejia324 488dd35
fix: 카카오 키 검증과 위치 조회 에러 처리 추가
leejia324 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 +1,2 @@ | ||
| BASE_URL= | ||
| KAKAO_API_KEY= |
This file contains hidden or 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 hidden or 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
Binary file not shown.
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,14 +1,79 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:moly_mobile/common/widgets/moly_scaffold.dart'; | ||
| import 'package:moly_mobile/core/constants/text_style.dart'; | ||
| import 'package:geolocator/geolocator.dart'; | ||
| import 'package:kakao_map_sdk/kakao_map_sdk.dart'; | ||
| import 'package:moly_mobile/features/map/presentation/widgets/location_dot.dart'; | ||
| import 'package:moly_mobile/features/map/presentation/widgets/map_fab.dart'; | ||
|
|
||
| class MapPage extends StatelessWidget { | ||
| class MapPage extends StatefulWidget { | ||
| const MapPage({super.key}); | ||
|
|
||
| @override | ||
| State<MapPage> createState() => _MapPageState(); | ||
| } | ||
|
|
||
| class _MapPageState extends State<MapPage> { | ||
| KakaoMapController? _controller; | ||
|
|
||
| Future<void> _moveToCurrentLocation() async { | ||
| try { | ||
| final position = await _currentPosition(); | ||
| final controller = _controller; | ||
| if (position == null || controller == null || !mounted) return; | ||
|
|
||
| final latLng = LatLng(position.latitude, position.longitude); | ||
| await controller.moveCamera( | ||
| CameraUpdate.newCenterPosition(latLng, zoomLevel: 18), | ||
| ); | ||
|
|
||
| if (!mounted) return; | ||
| final icon = await KImage.fromWidget( | ||
| const LocationDot(), | ||
| const Size(60, 60), | ||
| context: context, | ||
| ); | ||
| await controller.labelLayer.addPoi( | ||
| latLng, | ||
| style: PoiStyle(icon: icon, anchor: const KPoint(0.5, 0.3)), | ||
| ); | ||
| } catch (e) { | ||
| debugPrint('현재 위치 이동 실패: $e'); | ||
| } | ||
| } | ||
|
|
||
| Future<Position?> _currentPosition() async { | ||
| if (!await Geolocator.isLocationServiceEnabled()) return null; | ||
|
|
||
| var permission = await Geolocator.checkPermission(); | ||
| if (permission == LocationPermission.denied) { | ||
| permission = await Geolocator.requestPermission(); | ||
| } | ||
| if (permission == LocationPermission.denied || | ||
| permission == LocationPermission.deniedForever) { | ||
| return null; | ||
| } | ||
|
|
||
| return Geolocator.getCurrentPosition(); | ||
|
leejia324 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return const MolyScaffold( | ||
| body: Center(child: Text('지도', style: MolyTextStyle.headline2)), | ||
| return Scaffold( | ||
| body: Stack( | ||
| children: [ | ||
| KakaoMap( | ||
| option: const KakaoMapOption( | ||
| position: LatLng(37.5665, 126.9780), | ||
| zoomLevel: 16, | ||
| mapType: MapType.normal, | ||
| ), | ||
| onMapReady: (controller) { | ||
| _controller = controller; | ||
| _moveToCurrentLocation(); | ||
| }, | ||
| ), | ||
| const MapFab(), | ||
|
leejia324 marked this conversation as resolved.
|
||
| ], | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or 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,28 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:moly_mobile/core/constants/color.dart'; | ||
|
|
||
| class LocationDot extends StatelessWidget { | ||
| const LocationDot({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Center( | ||
| child: Container( | ||
| width: 20, | ||
| height: 20, | ||
| decoration: BoxDecoration( | ||
| shape: BoxShape.circle, | ||
| color: MolyColor.brown100, | ||
| border: Border.all(color: MolyColor.white, width: 2.5), | ||
| boxShadow: [ | ||
| BoxShadow( | ||
| color: MolyColor.brown100.withValues(alpha: 0.45), | ||
| blurRadius: 2, | ||
| spreadRadius: 3, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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,122 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:moly_mobile/core/constants/color.dart'; | ||
| import 'package:moly_mobile/core/constants/text_style.dart'; | ||
|
|
||
| class MapFab extends StatefulWidget { | ||
| const MapFab({super.key, this.onTimeCapsule, this.onMemo}); | ||
|
|
||
| final VoidCallback? onTimeCapsule; | ||
| final VoidCallback? onMemo; | ||
|
|
||
| @override | ||
| State<MapFab> createState() => _MapFabState(); | ||
| } | ||
|
|
||
| class _MapFabState extends State<MapFab> with SingleTickerProviderStateMixin { | ||
| late final AnimationController _controller = AnimationController( | ||
| vsync: this, | ||
| duration: const Duration(milliseconds: 130), | ||
| ); | ||
| bool _open = false; | ||
|
|
||
| void _toggle() { | ||
| setState(() => _open = !_open); | ||
| _open ? _controller.forward() : _controller.reverse(); | ||
| } | ||
|
|
||
| void _run(VoidCallback? action) { | ||
| _toggle(); | ||
| action?.call(); | ||
| } | ||
|
|
||
| @override | ||
| void dispose() { | ||
| _controller.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Stack( | ||
| children: [ | ||
| if (_open) | ||
| Positioned.fill( | ||
| child: GestureDetector( | ||
| onTap: _toggle, | ||
| child: ColoredBox( | ||
| color: MolyColor.black.withValues(alpha: 0.3), | ||
| ), | ||
| ), | ||
| ), | ||
| Positioned( | ||
| right: 20, | ||
| bottom: 40, | ||
| child: Column( | ||
| mainAxisSize: MainAxisSize.min, | ||
| crossAxisAlignment: CrossAxisAlignment.end, | ||
| children: [_menu(), const SizedBox(height: 16), _fab()], | ||
| ), | ||
| ), | ||
| ], | ||
| ); | ||
| } | ||
|
|
||
| Widget _menu() { | ||
| return SizeTransition( | ||
| sizeFactor: CurvedAnimation(parent: _controller, curve: Curves.easeOut), | ||
| alignment: Alignment.bottomCenter, | ||
| child: FadeTransition( | ||
| opacity: _controller, | ||
| child: Column( | ||
| crossAxisAlignment: CrossAxisAlignment.end, | ||
| children: [ | ||
| _action('타임캡슐 만들기', () => _run(widget.onTimeCapsule)), | ||
| const SizedBox(height: 12), | ||
| _action('메모 만들기', () => _run(widget.onMemo)), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| Widget _action(String label, VoidCallback onTap) { | ||
| return GestureDetector( | ||
| onTap: onTap, | ||
| child: Container( | ||
| padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6), | ||
| decoration: BoxDecoration( | ||
| color: MolyColor.white, | ||
| borderRadius: BorderRadius.circular(40), | ||
| boxShadow: [ | ||
| BoxShadow( | ||
| color: MolyColor.black.withValues(alpha: 0.1), | ||
| blurRadius: 8, | ||
| ), | ||
| ], | ||
| ), | ||
| child: Text( | ||
| label, | ||
| style: MolyTextStyle.captionMedium.copyWith(color: MolyColor.gray300), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| Widget _fab() { | ||
| return GestureDetector( | ||
| onTap: _toggle, | ||
| child: Container( | ||
| width: 64, | ||
| height: 64, | ||
| decoration: const BoxDecoration( | ||
| color: MolyColor.brown100, | ||
| shape: BoxShape.circle, | ||
| ), | ||
| child: RotationTransition( | ||
| turns: Tween<double>(begin: 0, end: 0.125).animate(_controller), | ||
| child: const Icon(Icons.add, color: MolyColor.white, size: 32), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.