Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #30 from Myzel394/migrate-to-flutter-map
Browse files Browse the repository at this point in the history
Migrate to flutter map
  • Loading branch information
Myzel394 authored May 30, 2023
2 parents ff01355 + 24de815 commit 4d44bfc
Show file tree
Hide file tree
Showing 18 changed files with 563 additions and 537 deletions.
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ PODS:
- Flutter
- map_launcher (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand Down Expand Up @@ -94,6 +96,7 @@ DEPENDENCIES:
- geocoding_ios (from `.symlinks/plugins/geocoding_ios/ios`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`)
- map_launcher (from `.symlinks/plugins/map_launcher/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- quick_actions_ios (from `.symlinks/plugins/quick_actions_ios/ios`)
Expand Down Expand Up @@ -138,6 +141,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/geolocator_apple/ios"
map_launcher:
:path: ".symlinks/plugins/map_launcher/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
Expand Down Expand Up @@ -168,6 +173,7 @@ SPEC CHECKSUMS:
geocoding_ios: a389ea40f6f548de6e63006a2e31bf66ff80769a
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
map_launcher: e325db1261d029ff33e08e03baccffe09593ffea
package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
Polyline: 2a1f29f87f8d9b7de868940f4f76deb8c678a5b1
Expand Down
10 changes: 10 additions & 0 deletions lib/App.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ class App extends StatelessWidget {
dialogBackgroundColor: settings.primaryColor == null
? darkColorScheme.background
: HSLColor.fromColor(settings.primaryColor!).withLightness(0.15).toColor(),
inputDecorationTheme: DARK_THEME_MATERIAL.inputDecorationTheme.copyWith(
fillColor: settings.primaryColor == null
? null
: HSLColor.fromColor(settings.primaryColor!).withLightness(0.3).withSaturation(.5).toColor(),
),
);
}

Expand All @@ -118,6 +123,11 @@ class App extends StatelessWidget {
dialogBackgroundColor: settings.primaryColor == null
? null
: HSLColor.fromColor(settings.primaryColor!).withLightness(0.15).toColor(),
inputDecorationTheme: DARK_THEME_MATERIAL.inputDecorationTheme.copyWith(
fillColor: settings.primaryColor == null
? null
: HSLColor.fromColor(settings.primaryColor!).withLightness(0.3).withSaturation(.5).toColor(),
),
);
})(),
themeMode: ThemeMode.system,
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -490,5 +490,6 @@
"logs_system_initiator_description": "This log was created by the system",
"logs_task_creationContext_description": "{context, select, inApp{Task created inside the App} quickAction{Task created via Quick Action} other{Unknown error occurred}}",
"logs_title": "Locus automatically creates logs",
"logs_description": "Logs are kept for 7 days and are automatically deleted afterwards."
"logs_description": "Logs are kept for 7 days and are automatically deleted afterwards.",
"locationPointsScreen_title": "Location Points"
}
10 changes: 5 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:disable_battery_optimization/disable_battery_optimization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:locus/App.dart';
import 'package:locus/services/app_update_service.dart';
Expand All @@ -29,13 +30,12 @@ void main() async {
Permission.locationAlways.isGranted,
TaskService.restore(),
ViewService.restore(),
Platform.isAndroid
? DisableBatteryOptimization.isBatteryOptimizationDisabled
: Future.value(true),
Platform.isAndroid ? DisableBatteryOptimization.isBatteryOptimizationDisabled : Future.value(true),
SettingsService.restore(),
hasGrantedNotificationPermission(),
LogService.restore(),
AppUpdateService.restore(),
FlutterMapTileCaching.initialise(),
]);
final bool hasLocationAlwaysGranted = futures[0];
final TaskService taskService = futures[1];
Expand All @@ -47,6 +47,7 @@ void main() async {
final AppUpdateService appUpdateService = futures[7];

await logService.deleteOldLogs();
await FMTC.instance('mapStore').manage.createAsync();

appUpdateService.checkForUpdates(force: true);

Expand All @@ -57,8 +58,7 @@ void main() async {
ChangeNotifierProvider<ViewService>(create: (_) => viewService),
ChangeNotifierProvider<SettingsService>(create: (_) => settingsService),
ChangeNotifierProvider<LogService>(create: (_) => logService),
ChangeNotifierProvider<AppUpdateService>(
create: (_) => appUpdateService),
ChangeNotifierProvider<AppUpdateService>(create: (_) => appUpdateService),
],
child: App(
hasLocationAlwaysGranted: hasLocationAlwaysGranted,
Expand Down
55 changes: 18 additions & 37 deletions lib/screens/CreateTaskScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart'
hide PlatformListTile;
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart' hide PlatformListTile;
import 'package:locus/constants/spacing.dart';
import 'package:locus/screens/create_task_screen_widgets/ExampleTasksRoulette.dart';
import 'package:locus/services/task_service.dart';
Expand Down Expand Up @@ -53,8 +52,7 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
_nameController.addListener(() {
final taskService = context.read<TaskService>();
final lowerCasedName = _nameController.text.toLowerCase();
final alreadyExists = taskService.tasks
.any((element) => element.name.toLowerCase() == lowerCasedName);
final alreadyExists = taskService.tasks.any((element) => element.name.toLowerCase() == lowerCasedName);

setState(() {
anotherTaskAlreadyExists = alreadyExists;
Expand Down Expand Up @@ -202,15 +200,12 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
autofillHints: const [AutofillHints.name],
material: (_, __) => MaterialTextFormFieldData(
decoration: InputDecoration(
labelText:
l10n.createTask_fields_name_label,
labelText: l10n.createTask_fields_name_label,
prefixIcon: Icon(context.platformIcons.tag),
),
),
cupertino: (_, __) =>
CupertinoTextFormFieldData(
placeholder:
l10n.createTask_fields_name_label,
cupertino: (_, __) => CupertinoTextFormFieldData(
placeholder: l10n.createTask_fields_name_label,
prefix: Icon(context.platformIcons.tag),
),
)
Expand Down Expand Up @@ -251,24 +246,19 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
direction: Axis.horizontal,
children: <Widget>[
PlatformElevatedButton(
material: (_, __) =>
MaterialElevatedButtonData(
material: (_, __) => MaterialElevatedButtonData(
icon: PlatformWidget(
material: (_, __) =>
const Icon(Icons.dns_rounded),
cupertino: (_, __) => const Icon(
CupertinoIcons.list_bullet),
material: (_, __) => const Icon(Icons.dns_rounded),
cupertino: (_, __) => const Icon(CupertinoIcons.list_bullet),
),
),
cupertino: (_, __) =>
CupertinoElevatedButtonData(
cupertino: (_, __) => CupertinoElevatedButtonData(
padding: getSmallButtonPadding(context),
),
onPressed: () {
showPlatformModalSheet(
context: context,
material: MaterialModalSheetData(
backgroundColor: Colors.transparent,
isScrollControlled: true,
isDismissible: true,
),
Expand All @@ -277,9 +267,8 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
),
);
},
child: Text(
l10n.createTask_fields_relays_selectLabel(
_relaysController.relays.length)),
child:
Text(l10n.createTask_fields_relays_selectLabel(_relaysController.relays.length)),
)
.animate()
.then(delay: IN_DELAY * 4)
Expand All @@ -294,19 +283,16 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
curve: Curves.easeOut,
),
PlatformElevatedButton(
material: (_, __) =>
MaterialElevatedButtonData(
material: (_, __) => MaterialElevatedButtonData(
icon: const Icon(Icons.timer_rounded),
),
cupertino: (_, __) =>
CupertinoElevatedButtonData(
cupertino: (_, __) => CupertinoElevatedButtonData(
padding: getSmallButtonPadding(context),
),
onPressed: () async {
await showPlatformModalSheet(
context: context,
material: MaterialModalSheetData(
backgroundColor: Colors.transparent,
isScrollControlled: true,
isDismissible: true,
),
Expand All @@ -316,8 +302,7 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
);
},
child: Text(
l10n.createTask_fields_timers_selectLabel(
_timersController.timers.length),
l10n.createTask_fields_timers_selectLabel(_timersController.timers.length),
),
)
.animate()
Expand All @@ -336,8 +321,7 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
),
const SizedBox(height: MEDIUM_SPACE),
PlatformListTile(
title:
Text(l10n.mainScreen_createTask_scheduleNow),
title: Text(l10n.mainScreen_createTask_scheduleNow),
leading: PlatformSwitch(
value: _scheduleNow,
onChanged: (value) {
Expand All @@ -352,14 +336,11 @@ class _CreateTaskScreenState extends State<CreateTaskScreen> {
showPlatformDialog(
context: context,
builder: (context) => PlatformAlertDialog(
title: Text(l10n
.mainScreen_createTask_scheduleNow_help_title),
content: Text(l10n
.mainScreen_createTask_scheduleNow_help_description),
title: Text(l10n.mainScreen_createTask_scheduleNow_help_title),
content: Text(l10n.mainScreen_createTask_scheduleNow_help_description),
actions: [
PlatformDialogAction(
child: PlatformText(
l10n.closeNeutralAction),
child: PlatformText(l10n.closeNeutralAction),
onPressed: () {
Navigator.of(context).pop();
},
Expand Down
8 changes: 5 additions & 3 deletions lib/screens/LocationPointsDetailsScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LocationPointsDetailsScreen extends StatelessWidget {
physics: isPreview ? const NeverScrollableScrollPhysics() : null,
itemCount: locations.length,
itemBuilder: (_, index) => LocationDetails(
location: locations[index],
location: locations[locations.length - index - 1],
isPreview: isPreview,
),
);
Expand All @@ -57,10 +57,12 @@ class LocationPointsDetailsScreen extends StatelessWidget {

return PlatformScaffold(
appBar: PlatformAppBar(
title: Text(
"Location Points",
title: Text(l10n.locationPointsScreen_title),
material: (_, __) => MaterialAppBarData(
centerTitle: true,
),
),
backgroundColor: Colors.transparent,
body: SafeArea(
child: content,
),
Expand Down
1 change: 0 additions & 1 deletion lib/screens/MainScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class _MainScreenState extends State<MainScreen> {
await showPlatformModalSheet(
context: context,
material: MaterialModalSheetData(
backgroundColor: Colors.transparent,
isScrollControlled: true,
isDismissible: true,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/SettingsScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
await showPlatformModalSheet(
context: context,
material: MaterialModalSheetData(
backgroundColor: Colors.transparent,
isScrollControlled: true,
isDismissible: true,
),
Expand Down Expand Up @@ -305,6 +304,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
onPressed: (_) async {
final shouldPopContext = await showPlatformModalSheet(
context: context,
material: MaterialModalSheetData(),
builder: (context) => ImportSheet(
onImport: (final taskService, final viewService, final settings) async {
await Future.wait([
Expand Down
29 changes: 29 additions & 0 deletions lib/screens/TaskDetailScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import 'package:locus/services/task_service.dart';
import 'package:locus/widgets/LocationFetchError.dart';
import 'package:locus/widgets/LocationsLoadingScreen.dart';
import 'package:locus/widgets/LocationsMap.dart';
import 'package:map_launcher/map_launcher.dart';

import '../api/get-locations.dart';
import '../constants/spacing.dart';
import '../widgets/LocationFetchEmpty.dart';
import '../widgets/OpenInMaps.dart';
import '../widgets/PlatformPopup.dart';

class TaskDetailScreen extends StatefulWidget {
final Task task;
Expand Down Expand Up @@ -104,6 +107,32 @@ class _TaskDetailScreenState extends State<TaskDetailScreen> {
cupertino: (_, __) => CupertinoNavigationBarData(
backgroundColor: CupertinoTheme.of(context).barBackgroundColor.withOpacity(.5),
),
trailingActions: _controller.locations.isNotEmpty
? [
PlatformPopup<String>(
type: PlatformPopupType.tap,
items: [
PlatformPopupMenuItem(
label: PlatformListTile(
leading: Icon(context.platformIcons.location),
trailing: const SizedBox.shrink(),
title: Text(l10n.viewDetails_actions_openLatestLocation),
),
onPressed: () async {
await showPlatformModalSheet(
context: context,
material: MaterialModalSheetData(),
builder: (context) => OpenInMaps(
destination:
Coords(_controller.locations.last.latitude, _controller.locations.last.longitude),
),
);
},
)
],
),
]
: [],
),
body: _isError
? const LocationFetchError()
Expand Down
Loading

0 comments on commit 4d44bfc

Please sign in to comment.