Geen omschrijving
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

absensi_screen.dart 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_map/plugin_api.dart';
  3. import 'package:geolocator/geolocator.dart';
  4. import 'package:google_maps_flutter/google_maps_flutter.dart';
  5. import 'package:hris_selfservice_mobile/Screens/Menu/Absensi/absensi_history_screen.dart';
  6. import 'package:latlong/latlong.dart' as latlong;
  7. import 'package:latlong2/latlong.dart';
  8. class AbsensiScreen extends StatefulWidget {
  9. const AbsensiScreen({Key? key}) : super(key: key);
  10. @override
  11. State<AbsensiScreen> createState() => _AbsensiScreenState();
  12. }
  13. class _AbsensiScreenState extends State<AbsensiScreen> {
  14. double long = 49.5;
  15. double lat = -0.09;
  16. latlong.LatLng point = latlong.LatLng(-6.186729296979901, 106.93023205185953);
  17. var location = [];
  18. @override
  19. Widget build(BuildContext context) {
  20. var size = MediaQuery.of(context).size;
  21. return Scaffold(
  22. body: SingleChildScrollView(
  23. child: Column(
  24. children: [
  25. Container(
  26. //Ganti yg ini untuk maps
  27. height: size.height * 0.3,
  28. child: FlutterMap(
  29. options: MapOptions(
  30. center: point,
  31. zoom: 10.0,
  32. ),
  33. children: [
  34. TileLayer(
  35. minZoom: 1,
  36. maxZoom: 18,
  37. backgroundColor: Colors.black54,
  38. urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  39. subdomains: ['a', 'b', 'c'],
  40. )
  41. ],
  42. )
  43. ),
  44. Container(
  45. width: double.infinity,
  46. margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
  47. decoration:
  48. BoxDecoration(border: Border.all(color: Colors.black)),
  49. child: Column(
  50. children: <Widget>[
  51. Container(
  52. child: Text("Attendance"),
  53. width: double.infinity,
  54. alignment: Alignment.center,
  55. decoration: BoxDecoration(
  56. gradient: LinearGradient(
  57. begin: Alignment.topRight,
  58. end: Alignment.bottomRight,
  59. colors: [
  60. Color(0xFFD21404),
  61. Color(0xFFFD7267),
  62. ]),
  63. border: Border.all(color: Colors.black)),
  64. ),
  65. Container(
  66. width: double.infinity,
  67. padding: EdgeInsets.all(15),
  68. child: Row(
  69. mainAxisAlignment: MainAxisAlignment.spaceAround,
  70. children: [
  71. Column(
  72. children: [
  73. Text('Check In'),
  74. Text('07.15'),
  75. ],
  76. ),
  77. Column(
  78. children: [
  79. Text('Check Out'),
  80. Text('16.45'),
  81. ],
  82. ),
  83. ],
  84. ),
  85. )
  86. ],
  87. ),
  88. ),
  89. Row(
  90. mainAxisAlignment: MainAxisAlignment.center,
  91. children: [
  92. Visibility(
  93. visible: true,
  94. child: ElevatedButton(
  95. onPressed: () {
  96. ScaffoldMessenger.of(context).showSnackBar(
  97. const SnackBar(content: Text('Check Status Button')));
  98. },
  99. child: Text('Check In'),
  100. style: ButtonStyle(
  101. backgroundColor: MaterialStateProperty.all(Colors.red)),
  102. ),
  103. ),
  104. Visibility(
  105. visible: false,
  106. child: ElevatedButton(
  107. onPressed: () {
  108. ScaffoldMessenger.of(context).showSnackBar(
  109. const SnackBar(content: Text('Check Status Button')));
  110. },
  111. child: Text('Check Out'),
  112. style: ButtonStyle(
  113. backgroundColor: MaterialStateProperty.all(Colors.red)),
  114. ),
  115. ),
  116. ],
  117. ),
  118. InkWell(
  119. child: Container(
  120. alignment: Alignment.centerRight,
  121. child:
  122. TextButton(onPressed: () {}, child: Text('View More...')),
  123. ),
  124. onTap: () {
  125. Navigator.push(context,
  126. MaterialPageRoute(builder: (context) => HistoryAbsensi()));
  127. },
  128. ),
  129. Container(
  130. width: double.infinity,
  131. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  132. padding: EdgeInsets.all(15),
  133. decoration:
  134. BoxDecoration(border: Border.all(color: Colors.black)),
  135. child: Column(
  136. children: [
  137. Row(
  138. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  139. children: [
  140. Text('Rabu, 23 November 2022', maxLines: 1),
  141. Column(
  142. children: [Text('Check In'), Text('07.00')],
  143. ),
  144. Column(
  145. children: [
  146. Text('Check Out'),
  147. Text('16.30'),
  148. ],
  149. ),
  150. ],
  151. ),
  152. Text('Location : Global Service Indonesia', maxLines: 1),
  153. ],
  154. )),
  155. Container(
  156. width: double.infinity,
  157. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  158. padding: EdgeInsets.all(15),
  159. decoration:
  160. BoxDecoration(border: Border.all(color: Colors.black)),
  161. child: Column(
  162. children: [
  163. Row(
  164. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  165. children: [
  166. Text('Rabu, 23 November 2022', maxLines: 1),
  167. Column(
  168. children: [Text('Check In'), Text('07.00')],
  169. ),
  170. Column(
  171. children: [
  172. Text('Check Out'),
  173. Text('16.30'),
  174. ],
  175. ),
  176. ],
  177. ),
  178. Text('Location : Global Service Indonesia', maxLines: 1),
  179. ],
  180. )),
  181. Container(
  182. width: double.infinity,
  183. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  184. padding: EdgeInsets.all(15),
  185. decoration:
  186. BoxDecoration(border: Border.all(color: Colors.black)),
  187. child: Column(
  188. children: [
  189. Row(
  190. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  191. children: [
  192. Text('Rabu, 23 November 2022', maxLines: 1),
  193. Column(
  194. children: [Text('Check In'), Text('07.00')],
  195. ),
  196. Column(
  197. children: [
  198. Text('Check Out'),
  199. Text('16.30'),
  200. ],
  201. ),
  202. ],
  203. ),
  204. Text('Location : Global Service Indonesia', maxLines: 1),
  205. ],
  206. )),
  207. Container(
  208. width: double.infinity,
  209. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  210. padding: EdgeInsets.all(15),
  211. decoration:
  212. BoxDecoration(border: Border.all(color: Colors.black)),
  213. child: Column(
  214. children: [
  215. Row(
  216. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  217. children: [
  218. Text('Rabu, 23 November 2022', maxLines: 1),
  219. Column(
  220. children: [Text('Check In'), Text('07.00')],
  221. ),
  222. Column(
  223. children: [
  224. Text('Check Out'),
  225. Text('16.30'),
  226. ],
  227. ),
  228. ],
  229. ),
  230. Text('Location : Global Service Indonesia', maxLines: 1),
  231. ],
  232. )),
  233. Container(
  234. width: double.infinity,
  235. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  236. padding: EdgeInsets.all(15),
  237. decoration:
  238. BoxDecoration(border: Border.all(color: Colors.black)),
  239. child: Column(
  240. children: [
  241. Row(
  242. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  243. children: [
  244. Text('Rabu, 23 November 2022', maxLines: 1),
  245. Column(
  246. children: [Text('Check In'), Text('07.00')],
  247. ),
  248. Column(
  249. children: [
  250. Text('Check Out'),
  251. Text('16.30'),
  252. ],
  253. ),
  254. ],
  255. ),
  256. Text('Location : Global Service Indonesia', maxLines: 1),
  257. ],
  258. )),
  259. Container(
  260. width: double.infinity,
  261. margin: EdgeInsets.fromLTRB(10, 10, 10, 0),
  262. padding: EdgeInsets.all(15),
  263. decoration:
  264. BoxDecoration(border: Border.all(color: Colors.black)),
  265. child: Column(
  266. children: [
  267. Row(
  268. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  269. children: [
  270. Text('Rabu, 23 November 2022', maxLines: 1),
  271. Column(
  272. children: [Text('Check In'), Text('07.00')],
  273. ),
  274. Column(
  275. children: [
  276. Text('Check Out'),
  277. Text('16.30'),
  278. ],
  279. ),
  280. ],
  281. ),
  282. Text('Location : Global Service Indonesia', maxLines: 1),
  283. ],
  284. )),
  285. /*SizedBox(
  286. */ /*child: GoogleMap(
  287. initialCameraPosition: initialCameraPosition,
  288. markers: markers,
  289. zoomControlsEnabled: false,
  290. mapType: MapType.normal,
  291. onMapCreated: (GoogleMapController controller) {
  292. googleMapController = controller;
  293. },
  294. ),
  295. ),*/ /*
  296. ),*/
  297. ],
  298. ),
  299. ),
  300. /* floatingActionButton: FloatingActionButton.extended(
  301. onPressed: () async {
  302. Position position = await _determinePosition();
  303. googleMapController
  304. .animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
  305. target: LatLng(position.latitude, position.longitude),
  306. zoom: 14)));
  307. markers.clear();
  308. markers.add(Marker(markerId: const MarkerId('currentLocation'),
  309. position: LatLng(position.latitude, position.longitude)));
  310. setState(() {});
  311. },
  312. label: Text("Current Location"),
  313. icon: Icon(Icons.location_history),),*/
  314. );
  315. }
  316. }
  317. /*_getCurrentLocation() {
  318. Geolocator
  319. .getCurrentPosition(desiredAccuracy: LocationAccuracy.best, forceAndroidLocationManager: true)
  320. .then((Position position) {
  321. setState(() {
  322. _currentPosition = position;
  323. _getAddressFromLatLng();
  324. });
  325. }).catchError((e) {
  326. print(e);
  327. });
  328. }*/
  329. /*
  330. Future<Position> _determinePosition() async {
  331. bool serviceEnabled;
  332. LocationPermission permission;
  333. serviceEnabled = await Geolocator.isLocationServiceEnabled();
  334. if (!serviceEnabled) {
  335. return Future.error('Location services are disabled');
  336. }
  337. permission = await Geolocator.checkPermission();
  338. if (permission == LocationPermission.denied) {
  339. permission = await Geolocator.requestPermission();
  340. if (permission == LocationPermission.denied) {
  341. return Future.error("Location permission denied");
  342. }
  343. }
  344. if (permission == LocationPermission.deniedForever) {
  345. return Future.error('Location permissions are permanently denied');
  346. }
  347. Position position = await Geolocator.getCurrentPosition();
  348. return position;
  349. }*/