Skip to content
Snippets Groups Projects
Commit 1dcbe671 authored by Andri Joos's avatar Andri Joos :blush:
Browse files

Merge branch '1-color_scheme' into 'master'

Resolve "Define color scheme"

Closes #1

See merge request !11
parents 92e89598 3980c379
No related branches found
No related tags found
1 merge request!11Resolve "Define color scheme"
Pipeline #5923 passed with stage
in 8 minutes and 21 seconds
......@@ -87,6 +87,10 @@ class App extends StatelessWidget {
title: "Car Tracker",
themeMode: ThemeMode.system,
darkTheme: ThemeData.dark(),
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)
),
initialRoute: TrackingRouting.route,
routes: {
TrackingRouting.route: (_) => const TrackingView(),
......
......@@ -58,6 +58,21 @@ class _CalendarState extends State<CalendarView> {
headerStyle: const HeaderStyle(
formatButtonShowsNext: false,
),
calendarStyle: CalendarStyle(
todayDecoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.inversePrimary,
),
selectedDecoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.primary,
),
markerDecoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.inverseSurface,
),
canMarkersOverflow: false,
),
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
onDaySelected: (selectedDay, focusedDay) {
......@@ -123,7 +138,9 @@ class _CalendarState extends State<CalendarView> {
margin: const EdgeInsets.only(right: 10, bottom: 10),
child: ElevatedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute<CalendarEvent>(builder: (context) => const CalendarEventView())).then((event) {
Navigator.push(context, MaterialPageRoute<CalendarEvent>(builder: (context) => CalendarEventView(
initialStartTime: viewModel.getSelectedDateWithCurrentTime(_selectedDay),
))).then((event) {
if (event != null) {
viewModel.addNewlyAddedCalendarEvent(event);
}
......
......@@ -14,18 +14,21 @@ import 'package:provider/provider.dart';
class CalendarEventView extends StatefulWidget {
final CalendarEvent? initialEvent;
final DateTime? initialStartTime;
const CalendarEventView({super.key, this.initialEvent});
const CalendarEventView({super.key, this.initialEvent, this.initialStartTime});
@override
// ignore: no_logic_in_create_state
State<StatefulWidget> createState() => _CalendarEventViewState(
initialEvent: initialEvent,
initialStartTime: initialStartTime
);
}
class _CalendarEventViewState extends State<CalendarEventView> {
final CalendarEvent? initialEvent;
final DateTime? initialStartTime;
final DateFormat standardFormat = DateFormat("dd.MM.yyyy HH:mm");
final TextEditingController _titleController = TextEditingController();
final TextEditingController _descriptionController = TextEditingController();
......@@ -54,7 +57,7 @@ class _CalendarEventViewState extends State<CalendarEventView> {
return initialEvent!.user.id == _currentUser!.id;
}
_CalendarEventViewState({required this.initialEvent});
_CalendarEventViewState({required this.initialEvent, required this.initialStartTime});
void setStartTime(DateTime time) {
setState(() {
......@@ -119,6 +122,9 @@ class _CalendarEventViewState extends State<CalendarEventView> {
if(startTime != null) {
setStartTime(startTime);
}
else if(initialStartTime != null) {
setStartTime(initialStartTime!);
}
else {
setStartTime(DateTime.now());
}
......
......@@ -97,14 +97,29 @@ class _TrackingViewState extends State<TrackingView> {
body: Consumer<TrackingViewModel>(
builder: (_, viewModel, __) {
return FlutterMap(
options: const MapOptions(
initialCenter: LatLng(58.9388, 5.6904),
options: MapOptions(
initialCenter: const LatLng(58.9388, 5.6904),
initialZoom: 15,
backgroundColor: Theme.of(context).colorScheme.background,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: "io.joos.car_app",
tileBuilder: (context, tileWidget, tile) {
if(Theme.of(context).brightness == Brightness.dark) {
return ColorFiltered(
colorFilter: const ColorFilter.matrix(<double>[
-1, 0, 0, 0, 255,
0, -1, 0, 0, 255,
0, 0, -1, 0, 255,
0, 0, 0, 1, 0,
]),
child: tileWidget,
);
}
return tileWidget;
},
),
PolylineLayer(
polylines: [
......
......@@ -145,4 +145,23 @@ class CalendarViewModel extends ChangeNotifier {
bool isEventFromCurrentUser(CalendarEvent event) {
return currentUser != null && event.user.id == currentUser!.id;
}
DateTime getSelectedDateWithCurrentTime(DateTime? selectedDay) {
var currentDateTime = DateTime.now();
if(selectedDay == null) {
return currentDateTime;
}
return DateTime(
selectedDay.year,
selectedDay.month,
selectedDay.day,
currentDateTime.hour,
currentDateTime.minute,
currentDateTime.second,
currentDateTime.millisecond,
currentDateTime.microsecond,
);
}
}
......@@ -31,7 +31,6 @@ dependencies:
flutter:
sdk: flutter
geolocator: ^11.0.0
# flutter_osm_plugin: ^0.70.4
provider: ^6.1.1
flutter_map: ^6.1.0
latlong2: ^0.9.0
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment