updated info text and time warning

This commit is contained in:
2024-03-27 19:30:54 +01:00
parent 4ecf44bafa
commit e748df092c
8 changed files with 166 additions and 113 deletions

View File

@ -1,15 +1,42 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class AppInfoView extends StatelessWidget {
const AppInfoView({super.key});
@override
Widget build(BuildContext context) {
return const AlertDialog(
title: Text("Achtung"),
content: Flexible(
child: Text("bla"),
return AlertDialog(
title: const Text("Information"),
content: const Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Diese App zeigt die Konsumverbotszonen für Cannabis."),
Text("Keinerlei Gewähr für Vollständigkeit, Richtigkeit und Aktualität!"),
SizedBox(height: 10),
Text("Prüfe selbst die Gesetzlichen Bestimmungen vor dem Besitz oder Konsum von Cannabis!", style: TextStyle(fontWeight: FontWeight.bold)),
SizedBox(height: 10),
Text("Die Daten beruhen auf OpenStreetMap, bearbeitet durch bubatzkarte.de."),
Text("Es besteht keinerlei Kooperation mit OpenStreetMap oder bubatzkarte.de.")
],
),
actions: [
TextButton(
child: const Text("bubatzkarte.de öffnen"),
onPressed: () => launchUrl(Uri.parse("https://bubatzkarte.de/")),
),
TextButton(
child: const Text("openstreetmap.org öffnen"),
onPressed: () => launchUrl(Uri.parse("https://www.openstreetmap.org/")),
),
TextButton(
child: const Text("Schließen"),
onPressed: () => Navigator.of(context).pop(),
),
],
);
}
}

View File

@ -4,7 +4,7 @@ import 'package:app/state/timeStatusState.dart';
import 'package:app/util/watchState.dart';
import 'package:app/view/appInfo.dart';
import 'package:app/view/locationSearch.dart';
import 'package:app/view/status.dart';
import 'package:app/view/timeWarning.dart';
import 'package:app/view/map.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
@ -66,11 +66,11 @@ class _HomePageState extends State<HomeView> {
IconButton(
icon: const Icon(Icons.search),
onPressed: () async {
MapState mapState = context.obtainState<MapState>();
LatLng? latLng = await showSearch<LatLng?>(
context: context,
delegate: LocationSearchDelegate(),
);
MapState mapState = context.obtainState<MapState>();
mapState.setActiveMarker(latLng);
if (latLng != null) {
mapState.getMapController.move(latLng, 16);
@ -112,12 +112,12 @@ class _HomePageState extends State<HomeView> {
),
body: Column(
children: [
WatchState<TimeStatusState>((context, state) {
if(state.isCurrentlyLegal) return const SizedBox.shrink();
WatchState<TimeWarningState>((context, state) {
if(!state.show) return const SizedBox.shrink();
return const SizedBox(
height: 100,
child: StatusView(),
child: TimeWarningView(),
);
}),
const Expanded(

View File

@ -1,61 +0,0 @@
import 'package:app/util/watchState.dart';
import 'package:flutter/material.dart';
import 'package:flutter_timer_countdown/flutter_timer_countdown.dart';
import '../state/timeStatusState.dart';
class StatusView extends StatelessWidget {
const StatusView({super.key});
@override
Widget build(BuildContext context) {
return WatchState<TimeStatusState>((context, state) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Center(
child: Icon(
Icons.timer_outlined,
size: 40,
),
),
const VerticalDivider(
endIndent: 20,
indent: 20,
color: Colors.white,
thickness: 3,
width: 40,
),
Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
"Ab 20 Uhr",
style: TextStyle(fontSize: 20),
),
TimerCountdown(
format: CountDownTimerFormat.hoursMinutesSeconds,
enableDescriptions: false,
spacerWidth: 5,
endTime: DateTime.now().add(state.remainingTimeUntilStart),
onEnd: () {
print("Timer finished");
},
),
],
),
),
],
)
);
});
}
}

57
lib/view/timeWarning.dart Normal file
View File

@ -0,0 +1,57 @@
import 'package:app/extensions/obtainProviderExtension.dart';
import 'package:flutter/material.dart';
import '../state/timeStatusState.dart';
class TimeWarningView extends StatelessWidget {
const TimeWarningView({super.key});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Center(
child: Icon(
Icons.warning_amber,
size: 40,
),
),
const VerticalDivider(
endIndent: 20,
indent: 20,
color: Colors.white,
thickness: 3,
width: 40,
),
const Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"In Fußgängerzone?",
style: TextStyle(fontSize: 20),
),
Flexible(
child: Text(
"hier ist der Konsum nur\nzwischen 20 und 7 Uhr gestattet!",
textAlign: TextAlign.center,
),
),
],
),
Center(
child: IconButton(
onPressed: context.obtainState<TimeWarningState>().hide,
icon: const Icon(Icons.close)
),
)
],
)
);
}
}