Created
October 16, 2021 13:03
-
-
Save mosluce/a3bc0efd3e92b090e02ba8b730b8e8ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:get/get.dart'; | |
import 'package:google_maps_flutter/google_maps_flutter.dart'; | |
import 'package:intl/intl.dart'; | |
import 'package:signbook/app/data/models/sign_model.dart'; | |
import '../controllers/map_controller.dart'; | |
class MapView extends GetView<MapController> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('路徑紀錄'), | |
centerTitle: true, | |
), | |
body: Obx(() { | |
if (controller.isLoading) { | |
return const Center( | |
child: CircularProgressIndicator(), | |
); | |
} | |
return Stack( | |
children: [ | |
GoogleMap( | |
mapType: MapType.normal, | |
initialCameraPosition: controller.initialCameraPosition, | |
onMapCreated: (mapCtrl) => controller.setMapController(mapCtrl), | |
markers: controller.markers, | |
polylines: controller.polylines, | |
), | |
SafeArea( | |
child: Row( | |
children: [ | |
Expanded( | |
child: Container( | |
margin: const EdgeInsets.all(8), | |
padding: const EdgeInsets.symmetric( | |
horizontal: 16, vertical: 4), | |
width: 100, | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(8), | |
color: Colors.white, | |
), | |
child: DropdownButton<Sign>( | |
onChanged: (sign) => controller.selectPoint(sign!), | |
value: controller.selectedPoint, | |
items: controller.checkPoints | |
.map( | |
(sign) => DropdownMenuItem( | |
value: sign, | |
child: Text( | |
'${sign.signer!.displayName} - ${DateFormat('yyyy-MM-dd HH:mm').format(sign.at!.toLocal())} - ${sign.action!}'), | |
), | |
) | |
.toList(), | |
), | |
), | |
), | |
], | |
), | |
), | |
], | |
); | |
}), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment