No Description
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

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