Skip to content

Commit

Permalink
refactor: MapActionsContainer.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Sep 9, 2023
1 parent 797b16e commit e304053
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 236 deletions.
110 changes: 52 additions & 58 deletions lib/screens/LocationsOverviewScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import 'package:locus/widgets/GoToMyLocationMapAction.dart';
import 'package:locus/widgets/LocationsMap.dart';
import 'package:locus/widgets/LocusFlutterMap.dart';
import 'package:locus/widgets/CompassMapAction.dart';
import 'package:locus/widgets/MapActionsContainer.dart';
import 'package:locus/widgets/Paper.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
Expand Down Expand Up @@ -1328,69 +1329,62 @@ class _LocationsOverviewScreenState extends State<LocationsOverviewScreen>
final shades = getPrimaryColorShades(context);

if (settings.getMapProvider() == MapProvider.openStreetMap) {
return Positioned(
// Add half the difference to center the button
right: FAB_MARGIN + diff / 2,
bottom: FAB_SIZE +
FAB_MARGIN +
(isCupertino(context) ? LARGE_SPACE : SMALL_SPACE),
child: Column(
children: [
AnimatedScale(
scale: showDetailedLocations ? 1 : 0,
duration:
showDetailedLocations ? 1200.milliseconds : 100.milliseconds,
curve: showDetailedLocations ? Curves.elasticOut : Curves.easeIn,
child: Tooltip(
message: disableShowDetailedLocations
? l10n.locationsOverview_mapAction_detailedLocations_show
: l10n.locationsOverview_mapAction_detailedLocations_hide,
preferBelow: false,
margin: const EdgeInsets.only(bottom: margin),
child: SizedBox.square(
dimension: dimension,
child: Center(
child: Paper(
width: null,
borderRadius: BorderRadius.circular(HUGE_SPACE),
padding: EdgeInsets.zero,
child: IconButton(
color: shades[400],
icon: Icon(disableShowDetailedLocations
? MdiIcons.mapMarkerMultipleOutline
: MdiIcons.mapMarkerMultiple),
onPressed: () {
setState(() {
disableShowDetailedLocations =
!disableShowDetailedLocations;
});
},
),
return MapActionsContainer(
children: [
AnimatedScale(
scale: showDetailedLocations ? 1 : 0,
duration:
showDetailedLocations ? 1200.milliseconds : 100.milliseconds,
curve: showDetailedLocations ? Curves.elasticOut : Curves.easeIn,
child: Tooltip(
message: disableShowDetailedLocations
? l10n.locationsOverview_mapAction_detailedLocations_show
: l10n.locationsOverview_mapAction_detailedLocations_hide,
preferBelow: false,
margin: const EdgeInsets.only(bottom: margin),
child: SizedBox.square(
dimension: dimension,
child: Center(
child: Paper(
width: null,
borderRadius: BorderRadius.circular(HUGE_SPACE),
padding: EdgeInsets.zero,
child: IconButton(
color: shades[400],
icon: Icon(disableShowDetailedLocations
? MdiIcons.mapMarkerMultipleOutline
: MdiIcons.mapMarkerMultiple),
onPressed: () {
setState(() {
disableShowDetailedLocations =
!disableShowDetailedLocations;
});
},
),
),
),
),
),
const SizedBox(height: SMALL_SPACE),
CompassMapAction(
onAlignNorth: () {
flutterMapController!.rotate(0);
},
mapController: flutterMapController!,
),
const SizedBox(height: SMALL_SPACE),
GoToMyLocationMapAction(
animate: locationStatus == LocationStatus.fetching,
onGoToMyLocation: () {
updateCurrentPosition(
askPermissions: true,
goToPosition: true,
showErrorMessage: true,
);
},
),
],
),
),
const SizedBox(height: SMALL_SPACE),
CompassMapAction(
onAlignNorth: () {
flutterMapController!.rotate(0);
},
mapController: flutterMapController!,
),
const SizedBox(height: SMALL_SPACE),
GoToMyLocationMapAction(
animate: locationStatus == LocationStatus.fetching,
onGoToMyLocation: () {
updateCurrentPosition(
askPermissions: true,
goToPosition: true,
showErrorMessage: true,
);
},
),
],
);
}

Expand Down
21 changes: 0 additions & 21 deletions lib/screens/ViewDetailsScreen.dart
Original file line number Diff line number Diff line change
@@ -1,45 +1,24 @@
import 'dart:async';

import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'
hide PlatformListTile;
import 'package:geolocator/geolocator.dart';
import 'package:locus/screens/view_alarm_screen_widgets/ViewAlarmScreen.dart';
import 'package:locus/screens/view_details_screen_widgets/LocationPointsList.dart';
import 'package:locus/screens/view_details_screen_widgets/ViewLocationPointsScreen.dart';
import 'package:locus/services/location_alarm_service.dart';
import 'package:locus/services/view_service.dart';
import 'package:locus/utils/PageRoute.dart';
import 'package:locus/utils/bunny.dart';
import 'package:locus/utils/permissions/has-granted.dart';
import 'package:locus/utils/permissions/request.dart';
import 'package:locus/widgets/EmptyLocationsThresholdScreen.dart';
import 'package:locus/widgets/FillUpPaint.dart';
import 'package:locus/widgets/LocationFetchEmpty.dart';
import 'package:locus/widgets/LocationsMap.dart';
import 'package:locus/widgets/OpenInMaps.dart';
import 'package:locus/widgets/Paper.dart';
import 'package:locus/widgets/PlatformFlavorWidget.dart';
import 'package:locus/widgets/PlatformPopup.dart';
import 'package:map_launcher/map_launcher.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import 'package:provider/provider.dart';

import '../constants/spacing.dart';
import '../services/location_fetch_controller.dart';
import '../services/location_point_service.dart';
import '../utils/theme.dart';
import '../widgets/LocationFetchError.dart';
import '../widgets/LocationStillFetchingBanner.dart';
import '../widgets/LocationsLoadingScreen.dart';
import '../widgets/PlatformListTile.dart';
import 'locations_overview_screen_widgets/LocationFetchers.dart';

const DEBOUNCE_DURATION = Duration(seconds: 2);

class ViewDetailsScreen extends StatefulWidget {
final TaskView view;

Expand Down
Loading

0 comments on commit e304053

Please sign in to comment.