diff --git a/app/lib/ui/flow/geofence/add/addnew/add_new_place_view.dart b/app/lib/ui/flow/geofence/add/addnew/add_new_place_view.dart index d4036af5..4cd17f1f 100644 --- a/app/lib/ui/flow/geofence/add/addnew/add_new_place_view.dart +++ b/app/lib/ui/flow/geofence/add/addnew/add_new_place_view.dart @@ -29,42 +29,47 @@ class _AddNewPlaceViewState extends ConsumerState { @override Widget build(BuildContext context) { notifier = ref.watch(addNewPlaceStateProvider.notifier); - final state = ref.watch(addNewPlaceStateProvider); _observeError(); return AppPage( title: context.l10n.add_new_place_title, - body: Padding( - padding: EdgeInsets.only( - left: 16, - right: 16, - bottom: context.mediaQueryPadding.bottom + 24, - ), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _searchTextField(), - const SizedBox(height: 40), - _locateOnMapView(), - const SizedBox(height: 40), - Text( - context.l10n.add_new_place_suggestion_text, - style: AppTextStyle.caption.copyWith( - color: context.colorScheme.textDisabled, - ), + body: _body(), + ); + } + + Widget _body() { + final state = ref.watch(addNewPlaceStateProvider); + + return Padding( + padding: EdgeInsets.only( + left: 16, + right: 16, + bottom: context.mediaQueryPadding.bottom + 24, + ), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _searchTextField(), + const SizedBox(height: 40), + _locateOnMapView(), + const SizedBox(height: 40), + Text( + context.l10n.add_new_place_suggestion_text, + style: AppTextStyle.caption.copyWith( + color: context.colorScheme.textDisabled, ), - const SizedBox(height: 16), - ...state.places.map((place) { - final isLast = - state.places.indexOf(place) == state.places.length - 1; - return _placesItemView(place, isLast); - }), - const SizedBox(height: 24), - state.loading ? const AppProgressIndicator() : Container(), - ], - ), + ), + const SizedBox(height: 16), + ...state.places.map((place) { + final isLast = + state.places.indexOf(place) == state.places.length - 1; + return _suggestedPlaceItemView(place, isLast); + }), + const SizedBox(height: 24), + state.loading ? const AppProgressIndicator() : Container(), + ], ), ), ); @@ -143,7 +148,7 @@ class _AddNewPlaceViewState extends ConsumerState { ); } - Widget _placesItemView(ApiNearbyPlace place, bool isLast) { + Widget _suggestedPlaceItemView(ApiNearbyPlace place, bool isLast) { return Column( children: [ Padding( diff --git a/app/lib/ui/flow/geofence/add/locate/locate_on_map_view.dart b/app/lib/ui/flow/geofence/add/locate/locate_on_map_view.dart index e30929ab..07aa926c 100644 --- a/app/lib/ui/flow/geofence/add/locate/locate_on_map_view.dart +++ b/app/lib/ui/flow/geofence/add/locate/locate_on_map_view.dart @@ -84,7 +84,9 @@ class _LocateOnMapViewState extends ConsumerState { ), Center(child: _locateMarkerView()), Align( - alignment: Alignment.bottomRight, child: _locateIconButton(context)) + alignment: Alignment.bottomRight, + child: _currentLocationIconView(context), + ) ]), ); } @@ -110,7 +112,7 @@ class _LocateOnMapViewState extends ConsumerState { ); } - Widget _locateIconButton(BuildContext context) { + Widget _currentLocationIconView(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24), child: IconPrimaryButton( diff --git a/app/lib/ui/flow/geofence/add/placename/choose_place_name_view.dart b/app/lib/ui/flow/geofence/add/placename/choose_place_name_view.dart index def8b8aa..0e23050f 100644 --- a/app/lib/ui/flow/geofence/add/placename/choose_place_name_view.dart +++ b/app/lib/ui/flow/geofence/add/placename/choose_place_name_view.dart @@ -46,34 +46,38 @@ class _ChoosePlaceNameViewState extends ConsumerState { @override Widget build(BuildContext context) { - final state = ref.watch(choosePlaceViewStateProvider); - _observeError(); _observePopToPlacesListScreen(); return AppPage( title: context.l10n.choose_place_screen_title, - body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _searchTextField(), - const SizedBox(height: 40), - Text( - context.l10n.choose_place_suggestion_text, - style: AppTextStyle.caption - .copyWith(color: context.colorScheme.textDisabled), - ), - const SizedBox(height: 16), - _suggestionsView(state.suggestions), - const Spacer(), - Align( - alignment: Alignment.center, - child: _addPlaceButtonView(state), - ) - ], - ), + body: _body(), + ); + } + + Widget _body() { + final state = ref.watch(choosePlaceViewStateProvider); + + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _searchTextField(), + const SizedBox(height: 40), + Text( + context.l10n.choose_place_suggestion_text, + style: AppTextStyle.caption + .copyWith(color: context.colorScheme.textDisabled), + ), + const SizedBox(height: 16), + _suggestionsPlaceView(state.suggestions), + const Spacer(), + Align( + alignment: Alignment.center, + child: _addPlaceButtonView(state), + ) + ], ), ); } @@ -117,7 +121,7 @@ class _ChoosePlaceNameViewState extends ConsumerState { ); } - Widget _suggestionsView(List? suggestions) { + Widget _suggestionsPlaceView(List? suggestions) { if (suggestions == null) return Container(); return Wrap( alignment: WrapAlignment.start, @@ -179,7 +183,7 @@ class _ChoosePlaceNameViewState extends ConsumerState { choosePlaceViewStateProvider.select((state) => state.popToPlaceList), (_, next) { AppRoute.popTo(context, AppRoute.pathPlacesList); - _showPlaceAddedPrompt( + _showPlaceAddedDialog( context, widget.location.latitude, widget.location.longitude, @@ -188,7 +192,7 @@ class _ChoosePlaceNameViewState extends ConsumerState { }); } - void _showPlaceAddedPrompt( + void _showPlaceAddedDialog( BuildContext context, double lat, double lng, diff --git a/app/lib/ui/flow/geofence/places/places_list_view.dart b/app/lib/ui/flow/geofence/places/places_list_view.dart index 2fafec41..b8eefe06 100644 --- a/app/lib/ui/flow/geofence/places/places_list_view.dart +++ b/app/lib/ui/flow/geofence/places/places_list_view.dart @@ -60,7 +60,7 @@ class _PlacesViewState extends ConsumerState { itemCount: placeLength + state.suggestions.length, itemBuilder: (_, index) { if (index < state.places.length) { - return _placesListItem(state, state.places[index]); + return _memberPlaceItem(state, state.places[index]); } if (index == state.places.length && state.places.isNotEmpty) { @@ -90,45 +90,7 @@ class _PlacesViewState extends ConsumerState { ); } - Widget _addPlaceButton() { - return OnTapScale( - onTap: () { - AppRoute.addNewPlace(widget.spaceId).push(context); - }, - child: Container( - margin: EdgeInsets.only( - right: 16, - bottom: context.mediaQueryPadding.bottom + 16, - ), - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30), - color: context.colorScheme.primary, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - SvgPicture.asset( - Assets.images.icPlusIcon, - colorFilter: ColorFilter.mode( - context.colorScheme.onPrimary, - BlendMode.srcATop, - ), - ), - const SizedBox(width: 8), - Text( - context.l10n.places_list_add_place_btn_text, - style: AppTextStyle.button.copyWith( - color: context.colorScheme.onPrimary, - ), - ) - ], - ), - ), - ); - } - - Widget _placesListItem(PlacesListState state, ApiPlace item) { + Widget _memberPlaceItem(PlacesListState state, ApiPlace item) { final icon = _getPlacesIcon(item.name); final isDeleting = state.deletingPlaces && state.placesToDelete?.id == item.id; @@ -205,6 +167,44 @@ class _PlacesViewState extends ConsumerState { ); } + Widget _addPlaceButton() { + return OnTapScale( + onTap: () { + AppRoute.addNewPlace(widget.spaceId).push(context); + }, + child: Container( + margin: EdgeInsets.only( + right: 16, + bottom: context.mediaQueryPadding.bottom + 16, + ), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + color: context.colorScheme.primary, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset( + Assets.images.icPlusIcon, + colorFilter: ColorFilter.mode( + context.colorScheme.onPrimary, + BlendMode.srcATop, + ), + ), + const SizedBox(width: 8), + Text( + context.l10n.places_list_add_place_btn_text, + style: AppTextStyle.button.copyWith( + color: context.colorScheme.onPrimary, + ), + ) + ], + ), + ), + ); + } + String _getPlacesIcon(String name) { if (name == 'Home') { return Assets.images.icPlacesHomeIcon; diff --git a/app/lib/ui/flow/geofence/places/places_list_view_model.dart b/app/lib/ui/flow/geofence/places/places_list_view_model.dart index b91978d5..9eefcfce 100644 --- a/app/lib/ui/flow/geofence/places/places_list_view_model.dart +++ b/app/lib/ui/flow/geofence/places/places_list_view_model.dart @@ -75,7 +75,7 @@ class PlacesListViewNotifier extends StateNotifier { } void dismissDeletePlaceDialog() { - state = state.copyWith(deletingPlaces: false, placesToDelete: null); + state = state.copyWith(placesToDelete: null); } void deletePlace() async {