123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- import 'dart:convert';
- import 'dart:typed_data';
-
- import 'package:double_back_to_close/double_back_to_close.dart';
- import 'package:flutter/material.dart';
- import 'package:fluttertoast/fluttertoast.dart';
- import 'package:google_fonts/google_fonts.dart';
- import 'package:hris_selfservice_mobile/Screens/Menu/About/about_screen.dart';
- import 'package:hris_selfservice_mobile/Screens/Menu/Absensi/absensi_screen.dart';
- import 'package:hris_selfservice_mobile/Screens/Menu/AjukanCuti/ajukancuti_screen.dart';
- import 'package:hris_selfservice_mobile/Screens/Menu/Reimburse/reimburse_screen.dart';
- import 'package:hris_selfservice_mobile/Screens/Menu/SlipGaji/slipgaji_screen.dart';
- import 'package:hris_selfservice_mobile/Screens/Menu/SuratTugas/surattugas_screen.dart';
- import 'package:hris_selfservice_mobile/Screens/Settings/settings_screen.dart';
- import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'dart:developer' as logDev;
- import '../Settings/RequestHttp/getDetail_post.dart';
- import '../Settings/RequestHttp/getProfileImage_post.dart';
- import 'package:location/location.dart';
-
-
- var _imageToShow;
- late String nameShared;
- String name = "",
- statusDetail = "",
- dateOfBirth = "",
- phone = "",
- email = "",
- address = "",
- position = "";
-
-
- class HomeView extends StatefulWidget {
- @override
- _HomeView createState() => _HomeView();
- }
-
- class _HomeView extends State<HomeView> {
- @override
- initState() {
- getDetail();
- _imageToShow = AssetImage('assets/images/ic_administrator.png');
- WidgetsBinding.instance.addPostFrameCallback((_) async {
- /* final location = await getLocation();
- logDev.log("Location: ${location.latitude}, ${location.longitude}");*/
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal,
- isDismissible: false,
- showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 5,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black,
- fontSize: 15.0,
- fontWeight: FontWeight.w600));
- loading.show();
- _imageToShow = getProfileImage();
- });
- }
-
- //Get Profile image
- getProfileImage() async {
- final SharedPreferences prefs = await SharedPreferences.getInstance();
- final session = prefs.getString('session');
-
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal,
- isDismissible: false,
- showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 5,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black,
- fontSize: 15.0,
- fontWeight: FontWeight.w600));
-
- GetProfileImage_Post.connectToAPI(session!).then((valueResult) async {
- Map<String, dynamic> object = json.decode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- String status = object['result']['status'].toString();
- logDev.log(status, name: "STATUS GET PROFILE");
- if (status == "success") {
- String photo = object['result']['photo'].toString();
- if (photo == "false") {
- setState(() {
- _imageToShow = AssetImage('assets/images/ic_administrator.png');
- });
- } else if (photo != "false") {
- Uint8List decodedBytes = Base64Decoder().convert(photo);
- logDev.log(decodedBytes.toString(), name: "DECODED BYTES photo");
- setState(() {
- _imageToShow = Image
- .memory(decodedBytes, gaplessPlayback: true)
- .image;
- });
- }
- } else if (status == "failed") {
- String message = object['result']['message'].toString();
- Fluttertoast.showToast(
- msg: message,
- toastLength: Toast.LENGTH_LONG,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);
- }
- loading.hide();
- } else {
- Fluttertoast.showToast(
- msg: "Server Response Error",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);
- loading.hide();
- }
- });
- return _imageToShow;
- }
-
- //GetDetail
- getDetail() async {
- final SharedPreferences prefs = await SharedPreferences.getInstance();
- final session = prefs.getString('session');
- GetDetail_Post.connectToAPI(session!).then((valueResult) async {
- Map<String, dynamic> object = json.decode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- statusDetail = object['result']['status'].toString();
- String message = object['result']['message'].toString();
- if (statusDetail == "failed" || message == "User Not Found") {
- Fluttertoast.showToast(
- msg: message + ", Please login again!",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);
- } else if (statusDetail != "failed") {
- name = object['result']['name'].toString();
- dateOfBirth = object['result']['date_of_birth'].toString();
- phone = object['result']['phone'].toString();
- email = object['result']['email'].toString();
- address = object['result']['address'].toString();
- position = object['result']['position'].toString();
- }
- } else {
- Fluttertoast.showToast(
- msg: "Server Response Error",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);
- }
- });
- }
-
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: DoubleBack(
- /*onFirstBackPress: (context) {
- final snackBar = SnackBar(content: Text("Double Back Press to Exit"));
- ScaffoldMessenger.of(context).showSnackBar(snackBar);
- },*/
- message: "Double Back Press to Exit",
- background: Colors.black38,
- backgroundRadius: 10,
- textStyle: TextStyle(
- fontSize: 16, fontWeight: FontWeight.bold, color: Colors.white),
- child: Scaffold(
- resizeToAvoidBottomInset: false,
- //backgroundColor: Colors.white,
- body: Stack(
- children: <Widget>[
- //Background(),
- HomeScreen(),
- ],
- )),
- ),
- );
- }
- }
-
- class HomeScreen extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- var size = MediaQuery.of(context).size;
- return Scaffold(
- body: SingleChildScrollView(
- child: Stack(
- children: <Widget>[
- Container(
- height: size.height * 0.3,
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topRight,
- end: Alignment.bottomRight,
- colors: [
- Color(0xFFD21404),
- Color(0xFFFD7267),
- ])),
- ),
- SafeArea(
- child: Padding(
- padding: EdgeInsets.all(20),
- child: Column(
- children: <Widget>[
- Align(
- alignment: Alignment.topRight,
- child: InkWell(
- child: Container(
- alignment: Alignment.center,
- height: 40,
- width: 40,
- child: Image.asset('assets/images/ic_settings.png')),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => SettingsScreen()));
- },
- ),
- ),
- Container(
- child: Stack(
- alignment: Alignment.topLeft,
- children: [
- Container(
- margin: EdgeInsets.only(top: ((size.width - 20) * 0.33) * 0.5),
- child: Card(
- elevation: 15,
- child: Container(
- height: size.width * 0.35,
- width: size.width - 20,
- padding: EdgeInsets.all(15),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius:
- BorderRadius.all(Radius.circular(10))),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.end,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Text(name,
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- textAlign: TextAlign.center,
- style: GoogleFonts.inter(
- fontSize: 18,
- color: Colors.black,
- fontWeight: FontWeight.bold),
- ),
- Text(position,
- textAlign: TextAlign.center,
- style: GoogleFonts.inter(
- fontSize: 17, color: Colors.black),
- ),
- ],
- )),
- ),
- ),
- Align(
- alignment: Alignment.topCenter,
- child: Container(
- margin: EdgeInsets.only(left: 15),
- alignment: Alignment.topLeft,
- height: (size.width - 20) * 0.33,
- width: (size.width - 20) * 0.33,
- decoration: BoxDecoration(
- color: Colors.black,
- image: DecorationImage(
- image: _imageToShow,
- fit: BoxFit.fill,
- ),
- shape: BoxShape.circle,
- ),
- ),
- ),
- ],
- ),
- ),
- GridView.count(
- shrinkWrap: true,
- physics: NeverScrollableScrollPhysics(),
- padding: EdgeInsets.only(top: 25, left: 5, right: 5),
- crossAxisSpacing: 15,
- mainAxisSpacing: 15,
- crossAxisCount: 2,
- children: <Widget>[
- InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 75,
- height: 75,
- child: Image.asset(
- "assets/icons/menu/ic_absensi.png",
- fit: BoxFit.fill,
- alignment: Alignment.center,
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'Absensi',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AbsensiScreen()));
- }),
- InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 75,
- height: 75,
- child: Image.asset(
- "assets/icons/menu/ic_slipgaji_2.png",
- fit: BoxFit.fill,
- alignment: Alignment.center),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'Slip Gaji',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => SlipGajiScreen()));
- },
- ),
- InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 70,
- height: 70,
- child: Image.asset(
- "assets/icons/menu/ic_cuti_2.png",
- fit: BoxFit.fill,
- alignment: Alignment.center),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'Ajukan Cuti',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AjukanCutiScreen()));
- },
- ),
- /*InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 75,
- height: 75,
- child: Image.asset(
- "assets/icons/menu/ic_menu_berita2.png"),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'Berita',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => BeritaScreen()));
- },
- ),*/
- InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 70,
- height: 70,
- child: Image.asset(
- "assets/icons/menu/ic_surattugas_2.png",
- fit: BoxFit.fill,
- alignment: Alignment.center,
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'Surat Tugas',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => SuratTugas_Screen()));
- },
- ),
- InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 70,
- height: 70,
- child: Image.asset(
- "assets/icons/menu/ic_reimburse.png",
- fit: BoxFit.fill,
- alignment: Alignment.center),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'Reimburse',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => ReimburseScreen()));
- },
- ),
- InkWell(
- child: Container(
- decoration: BoxDecoration(
- color: Color(0xFFD0D0D0),
- borderRadius: BorderRadius.circular(5)),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Container(
- width: 70,
- height: 70,
- child: Image.asset(
- "assets/icons/menu/ic_about_2.png",
- fit: BoxFit.fill,
- alignment: Alignment.center),
- ),
- Container(
- margin: EdgeInsets.only(top: 10),
- child: Text(
- 'About',
- textAlign: TextAlign.center,
- style: GoogleFonts.acme(
- fontSize: 18, color: Colors.black),
- ),
- ),
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => AboutScreen()));
- },
- ),
- ],
- )
- ],
- ),
- ),
- ),
- ],
- ),
- ));
- }
- }
|