wip countdown timer
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
|
||||
import 'package:app/extensions/obtainProviderExtension.dart';
|
||||
import 'package:app/state/mapState.dart';
|
||||
import 'package:app/state/timeStatusState.dart';
|
||||
import 'package:app/util/loadingContainer.dart';
|
||||
import 'package:app/util/watchState.dart';
|
||||
import 'package:app/view/appInfo.dart';
|
||||
@ -46,10 +48,14 @@ class _HomePageState extends State<HomeView> {
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 100,
|
||||
child: StatusView(),
|
||||
),
|
||||
WatchState<TimeStatusState>((context, state) {
|
||||
if(state.isCurrentlyLegal) return const SizedBox.shrink();
|
||||
|
||||
return const SizedBox(
|
||||
height: 100,
|
||||
child: StatusView(),
|
||||
);
|
||||
}),
|
||||
Expanded(
|
||||
child: Consumer<MapState>(
|
||||
builder: (context, state, child) {
|
||||
|
@ -1,3 +1,5 @@
|
||||
import 'package:app/extensions/obtainProviderExtension.dart';
|
||||
import 'package:app/state/mapState.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:http/http.dart';
|
||||
@ -15,6 +17,7 @@ class _MapViewState extends State<MapView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FlutterMap(
|
||||
mapController: context.obtainState<MapState>().getMapController,
|
||||
options: const MapOptions(
|
||||
initialCenter: LatLng(50.354, 7.5845),
|
||||
initialZoom: 16,
|
||||
@ -26,9 +29,9 @@ class _MapViewState extends State<MapView> {
|
||||
TileLayer(
|
||||
urlTemplate: "https://bubatzkarte.de/tiles/radius/100/{z}/{x}/{y}.png",
|
||||
tileProvider: NetworkTileProvider(
|
||||
httpClient: RetryClient(
|
||||
Client(),
|
||||
when: (response) => response.statusCode == 502)
|
||||
httpClient: RetryClient(
|
||||
Client(),
|
||||
when: (response) => response.statusCode == 502)
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -1,25 +1,26 @@
|
||||
import 'package:app/util/watchState.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_timer_countdown/flutter_timer_countdown.dart';
|
||||
|
||||
import '../state/legalStatusState.dart';
|
||||
import '../state/timeStatusState.dart';
|
||||
|
||||
class StatusView extends StatelessWidget {
|
||||
const StatusView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WatchState<LegalStatusState>((context, state) {
|
||||
return WatchState<TimeStatusState>((context, state) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: state.info.color
|
||||
color: Theme.of(context).colorScheme.surface
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
const Center(
|
||||
child: Icon(
|
||||
state.info.icon,
|
||||
Icons.timer_outlined,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
@ -28,7 +29,7 @@ class StatusView extends StatelessWidget {
|
||||
indent: 20,
|
||||
color: Colors.white,
|
||||
thickness: 3,
|
||||
width: 30,
|
||||
width: 40,
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
@ -36,21 +37,22 @@ class StatusView extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
state.info.title,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
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");
|
||||
},
|
||||
),
|
||||
Text(state.info.subtitle),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.info_outline),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
|
Reference in New Issue
Block a user