added legal state bar content
This commit is contained in:
parent
a718e02827
commit
10b0c59c3f
11
lib/model/stateInfo.dart
Normal file
11
lib/model/stateInfo.dart
Normal file
@ -0,0 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class StateInfo {
|
||||
IconData icon;
|
||||
Color color;
|
||||
String title;
|
||||
String subtitle;
|
||||
String description;
|
||||
|
||||
StateInfo({required this.icon, required this.color, required this.title, required this.subtitle, required this.description});
|
||||
}
|
@ -1,11 +1,54 @@
|
||||
import 'package:app/model/legelState.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:app/model/stateInfo.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LegalStatusState extends ChangeNotifier {
|
||||
LegalState _legalState = LegalState.unknown;
|
||||
|
||||
LegalState get getLegalState => _legalState;
|
||||
|
||||
StateInfo get info {
|
||||
switch(_legalState) {
|
||||
case LegalState.allowed:
|
||||
return StateInfo(
|
||||
icon: Icons.check,
|
||||
color: Colors.lightGreen,
|
||||
title: "Passt",
|
||||
subtitle: "Alle kriterien erfüllt",
|
||||
description: "asd"
|
||||
);
|
||||
|
||||
case LegalState.disallowedTime:
|
||||
return StateInfo(
|
||||
icon: Icons.timer_outlined,
|
||||
color: Colors.amber,
|
||||
title: "Zu früh",
|
||||
subtitle: "Bubazen ist nur zwischn 20 und 6 uhr Abends/ Nachts erlaubt!",
|
||||
description: "asd"
|
||||
);
|
||||
|
||||
case LegalState.disallowedRegion:
|
||||
return StateInfo(
|
||||
icon: Icons.location_off_outlined,
|
||||
color: Colors.red,
|
||||
title: "Zu nah an einem geschützen Gebäude",
|
||||
subtitle: "asd",
|
||||
description: "asd"
|
||||
);
|
||||
|
||||
case LegalState.unknown:
|
||||
default:
|
||||
return StateInfo(
|
||||
icon: Icons.question_mark_outlined,
|
||||
color: Colors.grey,
|
||||
title: "Status nicht bekannt",
|
||||
subtitle: "asd",
|
||||
description: "asd"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set setInSightOfDisallowedAreas(bool isInSight) {
|
||||
_legalState = LegalState.disallowedRegion;
|
||||
notifyListeners();
|
||||
|
12
lib/util/watchState.dart
Normal file
12
lib/util/watchState.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class WatchState<T> extends StatelessWidget {
|
||||
final Widget Function(BuildContext context, T state) child;
|
||||
const WatchState(this.child, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<T>(builder: (BuildContext context, T value, Widget? child) => this.child(context, value));
|
||||
}
|
||||
}
|
15
lib/view/appInfo.dart
Normal file
15
lib/view/appInfo.dart
Normal file
@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.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"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
import 'package:app/extensions/obtainProviderExtension.dart';
|
||||
import 'package:app/state/mapState.dart';
|
||||
import 'package:app/view/legalStatus.dart';
|
||||
import 'package:app/util/watchState.dart';
|
||||
import 'package:app/view/appInfo.dart';
|
||||
import 'package:app/view/status.dart';
|
||||
import 'package:app/view/map.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class HomeView extends StatefulWidget {
|
||||
const HomeView({super.key});
|
||||
@ -19,17 +20,33 @@ class _HomePageState extends State<HomeView> {
|
||||
appBar: AppBar(
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
title: const Text("Bubatzkarte"),
|
||||
actions: [],
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.info_outline),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => const AppInfoView(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: Consumer<MapState>(builder: (context, value, child) => Icon(value.followLocation ? Icons.my_location : Icons.location_disabled)),
|
||||
child: WatchState<MapState>((context, state) => Icon(state.followLocation ? Icons.my_location : Icons.location_disabled)),
|
||||
onPressed: () => context.obtainState<MapState>().toggleLocationLock(),
|
||||
),
|
||||
body: const Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: LegalStatusView(),
|
||||
child: StatusView(),
|
||||
),
|
||||
Expanded(
|
||||
child: MapView(),
|
||||
|
@ -1,21 +0,0 @@
|
||||
import 'package:app/state/legalStatusState.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class LegalStatusView extends StatefulWidget {
|
||||
const LegalStatusView({super.key});
|
||||
|
||||
@override
|
||||
State<LegalStatusView> createState() => _LegalStatusViewState();
|
||||
}
|
||||
|
||||
class _LegalStatusViewState extends State<LegalStatusView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<LegalStatusState>(
|
||||
builder: (context, value, child) {
|
||||
return Placeholder();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,15 +1,59 @@
|
||||
import 'package:app/util/watchState.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StatusView extends StatefulWidget {
|
||||
import '../state/legalStatusState.dart';
|
||||
|
||||
class StatusView extends StatelessWidget {
|
||||
const StatusView({super.key});
|
||||
|
||||
@override
|
||||
State<StatusView> createState() => _StatusViewState();
|
||||
}
|
||||
|
||||
class _StatusViewState extends State<StatusView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
return WatchState<LegalStatusState>((context, state) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: state.info.color
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Icon(
|
||||
state.info.icon,
|
||||
size: 40,
|
||||
),
|
||||
),
|
||||
const VerticalDivider(
|
||||
endIndent: 20,
|
||||
indent: 20,
|
||||
color: Colors.white,
|
||||
thickness: 3,
|
||||
width: 30,
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
state.info.title,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
Text(state.info.subtitle),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.info_outline),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user