-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera_route.dart
74 lines (67 loc) · 2.47 KB
/
camera_route.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import 'dart:async';
import 'package:design_system_flutter/design_system_flutter.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sbb_maps_example/env.dart';
import 'package:sbb_maps_example/theme_provider.dart';
import 'package:sbb_maps_flutter/sbb_maps_flutter.dart';
final _kCameraBern = SBBCameraUpdate.newLatLngZoom(const LatLng(46.947456, 7.451123), 14.0);
final _kCameraZurich = SBBCameraUpdate.newLatLngZoom(const LatLng(47.3769, 8.5417), 15.0);
class CameraRoute extends StatefulWidget {
const CameraRoute({super.key});
@override
State<CameraRoute> createState() => _CameraRouteState();
}
class _CameraRouteState extends State<CameraRoute> {
final Completer<SBBMapController> mapController = Completer();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
final mapStyler = SBBRokasMapStyler.full(
apiKey: Env.journeyMapsTilesApiKey,
isDarkMode: Provider.of<ThemeProvider>(context).isDark,
);
return Scaffold(
appBar: const SBBHeader(title: 'Camera'),
body: SafeArea(
child: Column(
children: [
Expanded(
child: SBBMap(
initialCameraPosition: const SBBCameraPosition(
target: LatLng(46.947456, 7.451123), // Bern
zoom: 8.0,
),
mapStyler: mapStyler,
isMyLocationEnabled: true,
onMapCreated: (controller) => mapController.complete(controller),
),
),
SBBGroup(
padding: const EdgeInsets.symmetric(horizontal: sbbDefaultSpacing / 2, vertical: sbbDefaultSpacing / 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SBBTertiaryButtonSmall(
label: 'Bern',
icon: SBBIcons.house_small,
onPressed: () => mapController.future.then((c) => c.animateCameraMove(cameraUpdate: _kCameraBern)),
),
SBBTertiaryButtonSmall(
label: 'Zurich',
icon: SBBIcons.station_small,
onPressed: () =>
mapController.future.then((c) => c.animateCameraMove(cameraUpdate: _kCameraZurich)),
)
],
),
)
],
),
),
);
}
}