From 89778e1461f3f194695cf971daa6bfcad0d386f7 Mon Sep 17 00:00:00 2001 From: Monkey D Luffy Date: Tue, 23 Jan 2024 14:32:59 +0800 Subject: [PATCH] fix: 23/01/2024 14:32 --- lib/main.dart | 2 +- lib/model/ModelQuery.dart | 2 + lib/screens/autentikasi/login/login.dart | 12 +- lib/screens/buku_tamu/buku_tamu.dart | 25 +- lib/screens/dashboard_screen.dart | 174 +++---- lib/screens/data_anggota/data_anggota.dart | 30 +- lib/screens/data_buku/data_buku.dart | 484 +++++++++--------- lib/screens/peminjaman/peminjaman.dart | 6 +- .../peminjaman/section/detail_peminjaman.dart | 10 +- lib/screens/pengembalian/pengembalian.dart | 8 +- .../section/detail_pengembalian.dart | 5 +- lib/screens/scan/scan.dart | 5 +- lib/screens/scan/section/scan_peminjaman.dart | 9 +- lib/services/FirebaseServices.dart | 20 +- lib/utils/Time.dart | 11 +- lib/utils/flutter_pdf_split.dart | 19 +- lib/widget/button/button_elevated_widget.dart | 2 +- lib/widget/gambar.dart | 1 + lib/widget/textfield/textfield_component.dart | 4 +- task.txt | 2 +- 20 files changed, 416 insertions(+), 415 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 4bdff83..e27aca3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget { return MaterialApp( debugShowCheckedModeBanner: false, // home: Login(), - home: DashboardScreen(), + home: const DashboardScreen(), navigatorKey: navigatorKey, ); } diff --git a/lib/model/ModelQuery.dart b/lib/model/ModelQuery.dart index 76117be..09d839c 100644 --- a/lib/model/ModelQuery.dart +++ b/lib/model/ModelQuery.dart @@ -1,3 +1,5 @@ +// ignore_for_file: file_names + class ModelQuery { String key; dynamic value; diff --git a/lib/screens/autentikasi/login/login.dart b/lib/screens/autentikasi/login/login.dart index d6b480d..74e0279 100644 --- a/lib/screens/autentikasi/login/login.dart +++ b/lib/screens/autentikasi/login/login.dart @@ -22,7 +22,7 @@ class Login extends StatelessWidget { body: Container( color: Colors.blue.shade700, child: Center( - child: Container( + child: SizedBox( width: 0.3.w, height: 0.5.h, child: Card( @@ -30,14 +30,14 @@ class Login extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(24), child: Column(children: [ - Center( + const Center( child: TextWidget( "Masuk", fontSize: 24, fontWeight: FontWeight.bold, )), V(8), - TextWidget("Silahkan login terlebih dahulu"), + const TextWidget("Silahkan login terlebih dahulu"), V(48), TextfieldComponent( hintText: "Email", @@ -50,7 +50,7 @@ class Login extends StatelessWidget { type: TypeTextField.password, ), V(32), - Container( + SizedBox( width: 100, child: ButtonElevatedWidget( "Masuk", @@ -58,11 +58,11 @@ class Login extends StatelessWidget { try { final emailTxt = emailController.text; final passTxt = passController.text; - print("$emailTxt => $passTxt"); await fs.signInWithEmailAndPassword( emailTxt, passTxt); - navigatePush(DashboardScreen()); + navigatePush(const DashboardScreen()); } catch (e) { + // ignore: use_build_context_synchronously context.showFastSnackbar("$e", color: TypeFastSnackbar.error); } diff --git a/lib/screens/buku_tamu/buku_tamu.dart b/lib/screens/buku_tamu/buku_tamu.dart index 22f93e9..0b4c79e 100644 --- a/lib/screens/buku_tamu/buku_tamu.dart +++ b/lib/screens/buku_tamu/buku_tamu.dart @@ -1,6 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; class BukuTamu extends StatefulWidget { const BukuTamu({Key? key}) : super(key: key); @@ -23,8 +22,8 @@ class _BukuTamuState extends State { return Expanded( child: Column( children: [ - Padding( - padding: const EdgeInsets.only( + const Padding( + padding: EdgeInsets.only( left: 20, right: 20, top: 30, bottom: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.start, @@ -39,7 +38,7 @@ class _BukuTamuState extends State { ), ), Padding( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( left: 10, right: 10, bottom: 40, top: 15), child: Column( children: [ @@ -49,7 +48,7 @@ class _BukuTamuState extends State { headingRowColor: MaterialStateProperty.resolveWith( (states) => Colors.blue.shade200), - columns: [ + columns: const [ DataColumn(label: Text("No anggota")), DataColumn(label: Text("Nama")), DataColumn(label: Text("Alamat")), @@ -63,29 +62,29 @@ class _BukuTamuState extends State { snapshot.data!.docs[index]; return DataRow(cells: [ - DataCell(Container( + DataCell(SizedBox( width: sizeColumn, child: Text(data['no_anggota']))), - DataCell(Container( + DataCell(SizedBox( width: sizeColumn, child: Text(data['nama']))), - DataCell(Container( + DataCell(SizedBox( width: sizeColumn, child: Text(data['alamat']))), - DataCell(Container( + DataCell(SizedBox( width: sizeColumn, child: Text(data['tanggal']))), - DataCell(Container( + DataCell(SizedBox( width: sizeColumn, child: Text(data['pekerjaan']))), - DataCell(Container( + DataCell(SizedBox( width: sizeColumn, child: Text(data['noHp']))), ]); })), ), //Now let's set the pagination - SizedBox( + const SizedBox( height: 40.0, ), ], @@ -95,7 +94,7 @@ class _BukuTamuState extends State { ), ); } else { - return Expanded( + return const Expanded( child: Center(child: CircularProgressIndicator()), ); } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index ac3b2d3..d421967 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -24,108 +24,104 @@ class _DashboardScreenState extends State { body: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - child: NavigationRail( - leading: Container( - child: Container( - margin: EdgeInsets.only(top: 5, bottom: 2), - child: Wrap(direction: Axis.vertical, children: [ - Wrap( - spacing: 5.0, - runSpacing: 3.0, - direction: Axis.horizontal, + NavigationRail( + leading: Container( + margin: const EdgeInsets.only(top: 5, bottom: 2), + child: Wrap(direction: Axis.vertical, children: [ + Wrap( + spacing: 5.0, + runSpacing: 3.0, + direction: Axis.horizontal, + children: [ + CircleAvatar( + backgroundColor: Colors.white, + backgroundImage: AssetImage(gambar.logo), + ), + const Wrap( + direction: Axis.vertical, children: [ - CircleAvatar( - backgroundColor: Colors.white, - backgroundImage: AssetImage(gambar.logo), + Text( + 'Perpustakaan Wilayah', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: Colors.white, + ), ), - Wrap( - direction: Axis.vertical, - children: [ - Text( - 'Perpustakaan Wilayah', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.w600, - color: Colors.white, - ), - ), - Text( - 'Sulawesi Selatan', - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.w600, - color: Colors.white, - ), - ), - ], + Text( + 'Sulawesi Selatan', + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: Colors.white, + ), ), ], ), - SizedBox( - height: 40, - width: 200, - child: Divider(color: Colors.white), - ), - ]), + ], ), + const SizedBox( + height: 40, + width: 200, + child: Divider(color: Colors.white), + ), + ]), + ), + extended: isExpanded, + backgroundColor: Colors.blue.shade700, + unselectedIconTheme: + const IconThemeData(color: Colors.white, opacity: 1), + unselectedLabelTextStyle: const TextStyle( + color: Colors.white, + ), + selectedIconTheme: IconThemeData(color: Colors.blue.shade300), + onDestinationSelected: (value) { + setState(() { + index = value; + }); + }, + destinations: const [ + NavigationRailDestination( + icon: Icon(Icons.qr_code), + label: Text("Scan"), ), - extended: isExpanded, - backgroundColor: Colors.blue.shade700, - unselectedIconTheme: - IconThemeData(color: Colors.white, opacity: 1), - unselectedLabelTextStyle: TextStyle( - color: Colors.white, + NavigationRailDestination( + icon: Icon(Icons.book), + label: Text("Data Buku"), ), - selectedIconTheme: IconThemeData(color: Colors.blue.shade300), - onDestinationSelected: (value) { - setState(() { - index = value; - }); - }, - destinations: [ - NavigationRailDestination( - icon: Icon(Icons.qr_code), - label: Text("Scan"), - ), - NavigationRailDestination( - icon: Icon(Icons.book), - label: Text("Data Buku"), - ), - NavigationRailDestination( - icon: Icon(Icons.bookmark_remove), - label: Text("Peminjaman"), - ), - // NavigationRailDestination( - // icon: Icon(Icons.person), - // label: Text("Profile"), - // ), - NavigationRailDestination( - icon: Icon(Icons.bookmark_add), - label: Text("Pengembalian"), - ), - NavigationRailDestination( - icon: Icon(Icons.menu_book), - label: Text("Buku tamu"), - ), - NavigationRailDestination( - icon: Icon(Icons.group), - label: Text("Data Anggota"), - ), - ], - selectedIndex: index), - ), + NavigationRailDestination( + icon: Icon(Icons.bookmark_remove), + label: Text("Peminjaman"), + ), + // NavigationRailDestination( + // icon: Icon(Icons.person), + // label: Text("Profile"), + // ), + NavigationRailDestination( + icon: Icon(Icons.bookmark_add), + label: Text("Pengembalian"), + ), + NavigationRailDestination( + icon: Icon(Icons.menu_book), + label: Text("Buku tamu"), + ), + NavigationRailDestination( + icon: Icon(Icons.group), + label: Text("Data Anggota"), + ), + ], + selectedIndex: index), index == 0 - ? Scan() + ? const Scan() : index == 1 - ? DataBuku() + ? const DataBuku() : index == 2 - ? Peminjaman() + ? const Peminjaman() : index == 3 - ? Pengembalian() + ? const Pengembalian() : index == 4 - ? BukuTamu() - : DataAnggota() + ? const BukuTamu() + : const DataAnggota() ], ), ); diff --git a/lib/screens/data_anggota/data_anggota.dart b/lib/screens/data_anggota/data_anggota.dart index 254672f..24b90d9 100644 --- a/lib/screens/data_anggota/data_anggota.dart +++ b/lib/screens/data_anggota/data_anggota.dart @@ -1,6 +1,5 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; class DataAnggota extends StatefulWidget { const DataAnggota({Key? key}) : super(key: key); @@ -21,29 +20,33 @@ class _DataAnggotaState extends State { return Expanded( child: Column( children: [ - Padding( - padding: const EdgeInsets.only(left: 20, right: 20, top: 30, bottom: 10), + const Padding( + padding: EdgeInsets.only( + left: 20, right: 20, top: 30, bottom: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( "Data Anggota", - style: TextStyle(fontSize: 25, fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 25, fontWeight: FontWeight.w600), ), ], ), ), Padding( - padding: EdgeInsets.only(left: 10, right: 10, bottom: 40, top: 15), + padding: const EdgeInsets.only( + left: 10, right: 10, bottom: 40, top: 15), child: Column( children: [ SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable( - headingRowColor: MaterialStateProperty.resolveWith( - (states) => Colors.blue.shade200), - columns: [ + headingRowColor: + MaterialStateProperty.resolveWith( + (states) => Colors.blue.shade200), + columns: const [ DataColumn(label: Text("No Anggota")), DataColumn(label: Text("Nama")), DataColumn(label: Text("Email")), @@ -53,9 +56,10 @@ class _DataAnggotaState extends State { DataColumn(label: Text("Nama Ibu")), DataColumn(label: Text("No Hp Ibu")), ], - rows: List.generate(snapshot.data!.docs.length, (index) { - DocumentSnapshot data = snapshot.data!.docs[index]; - + rows: List.generate( + snapshot.data!.docs.length, (index) { + DocumentSnapshot data = + snapshot.data!.docs[index]; return DataRow(cells: [ DataCell(Text(data['no_anggota'])), @@ -70,7 +74,7 @@ class _DataAnggotaState extends State { })), ), //Now let's set the pagination - SizedBox( + const SizedBox( height: 40.0, ), ], @@ -80,7 +84,7 @@ class _DataAnggotaState extends State { ), ); } else { - return Expanded( + return const Expanded( child: Center(child: CircularProgressIndicator()), ); } diff --git a/lib/screens/data_buku/data_buku.dart b/lib/screens/data_buku/data_buku.dart index 4a68fb9..8216ac0 100644 --- a/lib/screens/data_buku/data_buku.dart +++ b/lib/screens/data_buku/data_buku.dart @@ -1,5 +1,6 @@ -import 'dart:io'; +// ignore_for_file: use_build_context_synchronously, non_constant_identifier_names +import 'dart:io'; import 'package:admin_perpustakaan/utils/log_utils.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:fast_snackbar/fast_snackbar.dart'; @@ -70,26 +71,26 @@ class _DataBukuState extends State { final imgTmp = await image.readAsBytes(); setImage(File(image.path), imgTmp); } on PlatformException catch (e) { - print("Failed pick image"); + log("failed pick image", v: e); } } - Future _selectDate( - BuildContext context, - ) async { - final selected = await showDatePicker( - context: context, - initialDate: selectedDate, - firstDate: DateTime(2000), - lastDate: DateTime(3000)); + // Future _selectDate( + // BuildContext context, + // ) async { + // final selected = await showDatePicker( + // context: context, + // initialDate: selectedDate, + // firstDate: DateTime(2000), + // lastDate: DateTime(3000)); - if (selected != null && selected != selectedDate) { - setState(() { - selectedDate = selected; - }); - } - return selectedDate; - } + // if (selected != null && selected != selectedDate) { + // setState(() { + // selectedDate = selected; + // }); + // } + // return selectedDate; + // } Future splitPDF(path) async { String? directory = await FilePickerWeb.platform.getDirectoryPath(); @@ -110,7 +111,7 @@ class _DataBukuState extends State { var snapshot = await FirebaseStorage.instance .ref() .child("images") - .child('${DateTime.now()}-${judul}-${barcode}.jpg') + .child('${DateTime.now()}-$judul-$barcode.jpg') .putData(image); var downloadUrl = await snapshot.ref.getDownloadURL(); @@ -144,7 +145,7 @@ class _DataBukuState extends State { Navigator.of(this.context).pop('dialog'); setLoad(false); defaultState(); - } on FirebaseException catch (e) { + } on FirebaseException catch (_) { Navigator.of(this.context).pop('dialog'); setLoad(false); } @@ -159,7 +160,7 @@ class _DataBukuState extends State { var snapshot = await FirebaseStorage.instance .ref() .child("images") - .child('${DateTime.now()}-${judul}-${barcode}.jpg') + .child('${DateTime.now()}-$judul-$barcode.jpg') .putData(image); downloadUrl = await snapshot.ref.getDownloadURL(); } @@ -195,7 +196,7 @@ class _DataBukuState extends State { Navigator.of(this.context).pop('dialog'); setLoad(false); defaultState(); - } on FirebaseException catch (e) { + } on FirebaseException catch (_) { Navigator.of(this.context).pop('dialog'); setLoad(false); } @@ -209,7 +210,7 @@ class _DataBukuState extends State { }; await doc.update(json); - } on FirebaseException catch (e) {} + } on FirebaseException catch (_) {} } Future setRecommend(String? value, String? id) async { @@ -220,7 +221,7 @@ class _DataBukuState extends State { }; await docUser.update(json); - } on FirebaseException catch (e) {} + } on FirebaseException catch (_) {} } Future deleteBook(String? id, BuildContext context, Function setLoad) async { @@ -232,7 +233,7 @@ class _DataBukuState extends State { Navigator.of(this.context).pop('dialog'); setLoad(false); - } on FirebaseException catch (e) { + } on FirebaseException catch (_) { Navigator.of(this.context).pop('dialog'); setLoad(false); } @@ -262,6 +263,7 @@ class _DataBukuState extends State { halaman = data['halaman']; sinopsis = data['sinopsis']; kategori = data['kategori']; + stokBuku = data['stok_buku']; barcode = data['barcode']; isPicked = false; image = Uint8List(8); @@ -284,28 +286,25 @@ class _DataBukuState extends State { padding: const EdgeInsets.all(20), child: Column( children: [ - Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - const Icon( - Icons.close, - color: Colors.white, - ), - const Text( - "Edit Buku", - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w700), - ), - InkWell( - child: const Icon(Icons.close), - onTap: () { - Navigator.of(context).pop('dialog'); - }), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Icon( + Icons.close, + color: Colors.white, + ), + const Text( + "Edit Buku", + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w700), + ), + InkWell( + child: const Icon(Icons.close), + onTap: () { + Navigator.of(context).pop('dialog'); + }), + ], ), Container( margin: const EdgeInsets.symmetric(vertical: 30), @@ -411,35 +410,33 @@ class _DataBukuState extends State { ], ), ), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ElevatedButton( - style: ElevatedButton.styleFrom( - primary: Colors.green, - padding: const EdgeInsets.symmetric( - vertical: 20, horizontal: 50), - textStyle: const TextStyle(fontSize: 16), - ), - onPressed: !_loading - ? () { - editBook(context, (bool val) { - setState(() { - _loading = val; - }); - }, data.id); - } - : null, - child: _loading - ? const CircularProgressIndicator( - strokeWidth: 2.0, - color: Colors.white, - ) - : const Text("Submit"), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 50), + textStyle: const TextStyle(fontSize: 16), ), - ], - ), + onPressed: !_loading + ? () { + editBook(context, (bool val) { + setState(() { + _loading = val; + }); + }, data.id); + } + : null, + child: _loading + ? const CircularProgressIndicator( + strokeWidth: 2.0, + color: Colors.white, + ) + : const Text("Submit"), + ), + ], ) ], )), @@ -467,6 +464,8 @@ class _DataBukuState extends State { Expanded( child: InteractiveViewer( constrained: false, + minScale: 0.1, + // transformationController: viewTransformationController, child: DataTable( headingRowColor: MaterialStateProperty.resolveWith( (states) => Colors.blue.shade200), @@ -477,7 +476,7 @@ class _DataBukuState extends State { DataColumn(label: Text("Penerbit")), DataColumn(label: Text("Kategori")), DataColumn(label: Text("Rak Buku")), - // DataColumn(label: Text("Stok Buku")), + DataColumn(label: Text("Stok Buku")), DataColumn(label: Text("Halaman")), DataColumn(label: Text("Gambar")), DataColumn(label: Text("Aksi")), @@ -488,15 +487,17 @@ class _DataBukuState extends State { final number = index + 1; - log("data", v: data.data()); - return DataRow(cells: [ DataCell(Text(number.toString())), DataCell(Text(data['judul_buku'])), DataCell(Text(data['pengarang'])), - DataCell(Text(data['penerbit'])), + DataCell(SizedBox( + width: 150, child: Text(data['penerbit']))), DataCell(Text(data['kategori'])), - DataCell(Text(data['rak'])), + DataCell(SizedBox( + width: 50, child: Text(data['rak']))), + DataCell(SizedBox( + width: 50, child: Text(data['stok_buku']))), // DataCell(Container( // constraints: BoxConstraints( // maxWidth: 100, @@ -506,13 +507,12 @@ class _DataBukuState extends State { // ), // )), DataCell(Text(data['halaman'])), - DataCell(Container( + DataCell(SizedBox( width: 50, height: 50, child: Image.network(data["image"]), )), - DataCell(Container( - child: Row( + DataCell(Row( children: [ InkWell( onTap: () { @@ -561,23 +561,20 @@ class _DataBukuState extends State { .all(20), child: Column( children: [ - Container( - child: - const Row( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - Text( - "Hapus Buku", - style: TextStyle( - fontSize: - 20, - fontWeight: - FontWeight.w700), - ), - ], - ), + const Row( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Text( + "Hapus Buku", + style: TextStyle( + fontSize: + 20, + fontWeight: + FontWeight.w700), + ), + ], ), Container( margin: const EdgeInsets @@ -595,69 +592,76 @@ class _DataBukuState extends State { fontWeight: FontWeight.w400), )), - Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment - .center, - children: [ - ElevatedButton( - style: ElevatedButton - .styleFrom( - primary: - Colors.red, - padding: const EdgeInsets - .symmetric( - vertical: - 20, - horizontal: - 30), - textStyle: - const TextStyle(fontSize: 16), - ), - onPressed: - () { - Navigator.of(context) - .pop("dialog"); - }, - child: const Text( - "Close"), + Row( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + ElevatedButton( + style: ElevatedButton + .styleFrom( + backgroundColor: + Colors + .red, + padding: const EdgeInsets + .symmetric( + vertical: + 20, + horizontal: + 30), + textStyle: + const TextStyle( + fontSize: 16), ), - const SizedBox( - width: 10, + onPressed: + () { + Navigator.of( + context) + .pop( + "dialog"); + }, + child: const Text( + "Close"), + ), + const SizedBox( + width: 10, + ), + ElevatedButton( + style: ElevatedButton + .styleFrom( + backgroundColor: + Colors + .green, + padding: const EdgeInsets + .symmetric( + vertical: + 20, + horizontal: + 30), + textStyle: + const TextStyle( + fontSize: 16), ), - ElevatedButton( - style: ElevatedButton - .styleFrom( - primary: - Colors.green, - padding: const EdgeInsets - .symmetric( - vertical: - 20, - horizontal: - 30), - textStyle: - const TextStyle(fontSize: 16), - ), - onPressed: !_loading - ? () { - deleteBook(data.id, context, (bool val) { - setState(() { - _loading = val; + onPressed: + !_loading + ? () { + deleteBook(data.id, context, (bool val) { + setState(() { + _loading = val; + }); }); - }); - } - : null, - child: _loading - ? const CircularProgressIndicator( - strokeWidth: 2.0, - color: Colors.white, - ) - : const Text("Ya"), - ), - ], - ), + } + : null, + child: _loading + ? const CircularProgressIndicator( + strokeWidth: + 2.0, + color: + Colors.white, + ) + : const Text("Ya"), + ), + ], ) ], )), @@ -734,7 +738,7 @@ class _DataBukuState extends State { // ), // ), ], - ))), + )), ]); })), ), @@ -801,44 +805,38 @@ class _DataBukuState extends State { ? isPicked ? InkWell( onTap: onPick, - child: Container( - child: Image.memory( - img!, - width: 120, - height: 120, - fit: BoxFit.fill, - ), + child: Image.memory( + img!, + width: 120, + height: 120, + fit: BoxFit.fill, ), ) : InkWell( onTap: onPick, - child: Container( - child: Image.network( - img1!, - width: 120, - height: 120, - fit: BoxFit.fill, - ), + child: Image.network( + img1!, + width: 120, + height: 120, + fit: BoxFit.fill, ), ) : tmpImage != null ? InkWell( onTap: onPick, - child: Container( - child: Image.memory( - img!, - width: 120, - height: 120, - fit: BoxFit.fill, - ), + child: Image.memory( + img!, + width: 120, + height: 120, + fit: BoxFit.fill, ), ) : InkWell( onTap: onPick, - child: Container( + child: const SizedBox( height: 100, width: 100, - child: const Icon(Icons.add_a_photo), + child: Icon(Icons.add_a_photo), ), ) ], @@ -873,9 +871,8 @@ class _DataBukuState extends State { decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5)), child: ElevatedButton( - child: const Text('Tambah Buku'), style: ElevatedButton.styleFrom( - primary: Colors.blueAccent, + backgroundColor: Colors.blueAccent, textStyle: const TextStyle(fontSize: 16)), onPressed: () { showDialog( @@ -894,32 +891,29 @@ class _DataBukuState extends State { padding: const EdgeInsets.all(20), child: Column( children: [ - Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - const Icon( - Icons.close, - color: Colors.white, - ), - const Text( - "Tambah Buku", - style: TextStyle( - fontSize: 20, - fontWeight: - FontWeight.w700), - ), - InkWell( - child: - const Icon(Icons.close), - onTap: () { - Navigator.of(context) - .pop('dialog'); - }), - ], - ), + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + const Icon( + Icons.close, + color: Colors.white, + ), + const Text( + "Tambah Buku", + style: TextStyle( + fontSize: 20, + fontWeight: + FontWeight.w700), + ), + InkWell( + child: + const Icon(Icons.close), + onTap: () { + Navigator.of(context) + .pop('dialog'); + }), + ], ), Container( margin: const EdgeInsets.symmetric( @@ -1038,41 +1032,38 @@ class _DataBukuState extends State { ], ), ), - Container( - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - ElevatedButton( - style: - ElevatedButton.styleFrom( - primary: Colors.green, - padding: const EdgeInsets - .symmetric( - vertical: 20, - horizontal: 50), - textStyle: const TextStyle( - fontSize: 16), - ), - onPressed: !_loading - ? () { - addBooks(context, - (bool val) { - setState(() { - _loading = val; - }); - }); - } - : null, - child: _loading - ? const CircularProgressIndicator( - strokeWidth: 2.0, - color: Colors.white, - ) - : const Text("Submit"), + Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.green, + padding: const EdgeInsets + .symmetric( + vertical: 20, + horizontal: 50), + textStyle: const TextStyle( + fontSize: 16), ), - ], - ), + onPressed: !_loading + ? () { + addBooks(context, + (bool val) { + setState(() { + _loading = val; + }); + }); + } + : null, + child: _loading + ? const CircularProgressIndicator( + strokeWidth: 2.0, + color: Colors.white, + ) + : const Text("Submit"), + ), + ], ) ], )), @@ -1080,7 +1071,8 @@ class _DataBukuState extends State { )); }); }); - }), + }, + child: const Text('Tambah Buku')), ), ])); } diff --git a/lib/screens/peminjaman/peminjaman.dart b/lib/screens/peminjaman/peminjaman.dart index d2ed189..39444c5 100644 --- a/lib/screens/peminjaman/peminjaman.dart +++ b/lib/screens/peminjaman/peminjaman.dart @@ -80,7 +80,7 @@ class _PeminjamanState extends State { ), Expanded( child: !isClick - ? listData.length > 0 + ? listData.isNotEmpty ? ListView.builder( itemCount: listData.length, itemBuilder: (context, index) { @@ -100,12 +100,12 @@ class _PeminjamanState extends State { "Jumlah peminjaman : ${data["jumlah_peminjaman"]}"), trailing: IconButton( onPressed: () {}, - icon: Icon(Icons.arrow_right)), + icon: const Icon(Icons.arrow_right)), ), ); }, ) - : Center(child: CircularProgressIndicator()) + : const Center(child: CircularProgressIndicator()) : DetailPeminjaman(id: email)) ]), ); diff --git a/lib/screens/peminjaman/section/detail_peminjaman.dart b/lib/screens/peminjaman/section/detail_peminjaman.dart index f3cb918..418d3f8 100644 --- a/lib/screens/peminjaman/section/detail_peminjaman.dart +++ b/lib/screens/peminjaman/section/detail_peminjaman.dart @@ -33,7 +33,6 @@ class _DetailPeminjamanState extends State { } void onPengembalian(Map data) { - print(data); fs.add("pengembalian", { "email": data["email"], "nama_peminjam": data["nama_peminjam"], @@ -109,8 +108,8 @@ class _DetailPeminjamanState extends State { label: TextWidget("Gambar", fontSize: fontSizeDataCell, fontWeight: FontWeight.bold)), - DataColumn(label: Text("")), - DataColumn(label: Text("")), + const DataColumn(label: Text("")), + const DataColumn(label: Text("")), // DataColumn(label: Text("")), ], rows: List.generate(size, (index) { @@ -168,7 +167,7 @@ class _DetailPeminjamanState extends State { DataCell(TextWidget(denda > 0 ? "$denda" : "-", fontSize: fontSizeDataCell)), DataCell(Container( - padding: EdgeInsets.symmetric(vertical: 8), + padding: const EdgeInsets.symmetric(vertical: 8), child: Image.network( data["image"]!, width: 50, @@ -216,7 +215,8 @@ class _DetailPeminjamanState extends State { })); } - return Expanded(child: Center(child: CircularProgressIndicator())); + return const Expanded( + child: Center(child: CircularProgressIndicator())); }), ); } diff --git a/lib/screens/pengembalian/pengembalian.dart b/lib/screens/pengembalian/pengembalian.dart index 540f14a..44c6d73 100644 --- a/lib/screens/pengembalian/pengembalian.dart +++ b/lib/screens/pengembalian/pengembalian.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/src/foundation/key.dart'; -import 'package:flutter/src/widgets/framework.dart'; import 'package:admin_perpustakaan/model/ModelQuery.dart'; import 'package:admin_perpustakaan/services/FirebaseServices.dart'; import 'package:admin_perpustakaan/widget/header/header_widget.dart'; @@ -83,7 +81,7 @@ class _PengembalianState extends State { ), Expanded( child: !isClick - ? listData.length > 0 + ? listData.isNotEmpty ? ListView.builder( itemCount: listData.length, itemBuilder: (context, index) { @@ -103,12 +101,12 @@ class _PengembalianState extends State { "Jumlah pengembalian : ${data["jumlah_pengembalian"]}"), trailing: IconButton( onPressed: () {}, - icon: Icon(Icons.arrow_right)), + icon: const Icon(Icons.arrow_right)), ), ); }, ) - : Center(child: CircularProgressIndicator()) + : const Center(child: CircularProgressIndicator()) : DetailPengembalian(id: email, onGetData: getData)) ]), ); diff --git a/lib/screens/pengembalian/section/detail_pengembalian.dart b/lib/screens/pengembalian/section/detail_pengembalian.dart index c3c4a3f..61131e0 100644 --- a/lib/screens/pengembalian/section/detail_pengembalian.dart +++ b/lib/screens/pengembalian/section/detail_pengembalian.dart @@ -78,7 +78,7 @@ class _DetailPengembalianState extends State { DataCell(TextWidget("${data['denda'] ?? "-"}", fontSize: fontSizeDataCell)), DataCell(Container( - padding: EdgeInsets.symmetric(vertical: 8), + padding: const EdgeInsets.symmetric(vertical: 8), child: Image.network( data["image"]!, width: 50, @@ -97,7 +97,8 @@ class _DetailPengembalianState extends State { })); } - return Expanded(child: Center(child: CircularProgressIndicator())); + return const Expanded( + child: Center(child: CircularProgressIndicator())); }), ); } diff --git a/lib/screens/scan/scan.dart b/lib/screens/scan/scan.dart index 601f87b..14e404d 100644 --- a/lib/screens/scan/scan.dart +++ b/lib/screens/scan/scan.dart @@ -30,7 +30,7 @@ class _ScanState extends State { Future.delayed(Duration.zero, () async { await dialogShow( context: context, - widget: Container( + widget: SizedBox( width: 0.4.w, height: found ? 0.8.h : 0.7.h, child: Column( @@ -111,7 +111,8 @@ class _ScanState extends State { return widgetMain(code); } - return Expanded(child: Center(child: CircularProgressIndicator())); + return const Expanded( + child: Center(child: CircularProgressIndicator())); }, ), ); diff --git a/lib/screens/scan/section/scan_peminjaman.dart b/lib/screens/scan/section/scan_peminjaman.dart index b2edb37..0461512 100644 --- a/lib/screens/scan/section/scan_peminjaman.dart +++ b/lib/screens/scan/section/scan_peminjaman.dart @@ -121,8 +121,8 @@ class _ScanPeminjamanState extends State { label: TextWidget("Gambar", fontSize: fontSizeDataCell, fontWeight: FontWeight.bold)), - DataColumn(label: Text("")), - DataColumn(label: Text("")), + const DataColumn(label: Text("")), + const DataColumn(label: Text("")), // DataColumn(label: Text("")), ], rows: List.generate(size, (index) { @@ -180,7 +180,7 @@ class _ScanPeminjamanState extends State { DataCell(TextWidget(denda > 0 ? "$denda" : "-", fontSize: fontSizeDataCell)), DataCell(Container( - padding: EdgeInsets.symmetric(vertical: 8), + padding: const EdgeInsets.symmetric(vertical: 8), child: Image.network( data["image"]!, width: 50, @@ -230,7 +230,8 @@ class _ScanPeminjamanState extends State { ]); } - return Expanded(child: Center(child: CircularProgressIndicator())); + return const Expanded( + child: Center(child: CircularProgressIndicator())); }), ); } diff --git a/lib/services/FirebaseServices.dart b/lib/services/FirebaseServices.dart index 54d1c2b..cf512dc 100644 --- a/lib/services/FirebaseServices.dart +++ b/lib/services/FirebaseServices.dart @@ -1,3 +1,5 @@ +// ignore_for_file: file_names + import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_auth/firebase_auth.dart'; @@ -17,7 +19,7 @@ class FirebaseServices { void add(String path, data) { _db.collection(path).add(data).then((DocumentReference doc) => - print('DocumentSnapshot added with ID: ${doc.id}')); + log('DocumentSnapshot added with ID', v: doc.id)); } Future>> getAll(String path) { @@ -32,9 +34,9 @@ class FirebaseServices { String path, List query) { Query> collection = _db.collection(path); - query.forEach((e) { + for (var e in query) { collection = collection.where(e.key, isEqualTo: e.value); - }); + } return collection.snapshots(); } @@ -43,9 +45,9 @@ class FirebaseServices { String path, List query) { Query> collection = _db.collection(path); - query.forEach((e) { + for (var e in query) { collection = collection.where(e.key, isEqualTo: e.value); - }); + } return collection.get(); } @@ -69,8 +71,8 @@ class FirebaseServices { .collection(path) .doc(id) .update(data) - .then((value) => print("sukses")) - .catchError((error) => print("Failed to update user: $error")); + .then((value) => log("sukses")) + .catchError((error) => log("Failed to update user: $error")); } void delete(String path, String id) { @@ -78,8 +80,8 @@ class FirebaseServices { .collection(path) .doc(id) .delete() - .then((value) => print('Berhasil menghapush data')) - .catchError((error) => print("Failed to delete user: $error")); + .then((value) => log('Berhasil menghapush data')) + .catchError((error) => log("Failed to delete user: $error")); } User? getCurrentUser() { diff --git a/lib/utils/Time.dart b/lib/utils/Time.dart index ac7f4b6..7fac874 100644 --- a/lib/utils/Time.dart +++ b/lib/utils/Time.dart @@ -1,12 +1,15 @@ +// ignore_for_file: file_names + +import 'package:admin_perpustakaan/utils/log_utils.dart'; import 'package:intl/intl.dart'; class Time { final _now = DateTime.now(); String getTimeNow() { - var formatter = new DateFormat('yyyy-MM-dd'); + var formatter = DateFormat('yyyy-MM-dd'); String formattedDate = formatter.format(_now); - print(formattedDate); // 2016-01-25 + log("formattedDate", v: formattedDate); // 2016-01-25 return formattedDate; } @@ -48,8 +51,8 @@ class Time { int getLastDateInMonth() { var lastDayDateTime = (_now.month < 12) - ? new DateTime(_now.year, _now.month + 1, 0) - : new DateTime(_now.year + 1, 1, 0); + ? DateTime(_now.year, _now.month + 1, 0) + : DateTime(_now.year + 1, 1, 0); return lastDayDateTime.day; } diff --git a/lib/utils/flutter_pdf_split.dart b/lib/utils/flutter_pdf_split.dart index 4eb50dc..f79ee8f 100644 --- a/lib/utils/flutter_pdf_split.dart +++ b/lib/utils/flutter_pdf_split.dart @@ -12,7 +12,8 @@ class FlutterPdfSplitArgs { /// Prefix for each pdf page file, default value is 'page_' final String outFilePrefix; - FlutterPdfSplitArgs(this.filePath, this.outDirectory, {this.outFilePrefix = "page_"}); + FlutterPdfSplitArgs(this.filePath, this.outDirectory, + {this.outFilePrefix = "page_"}); Map get toMap => { "filePath": filePath, @@ -29,16 +30,16 @@ class FlutterPdfSplitResult { : assert(result.containsKey("pageCount") && result.containsKey("pagePaths") && result["pagePaths"] is List) { - this.pageCount = result["pageCount"]; - this.pagePaths = []; - (result["pagePaths"] as List).forEach((path) { - if (path is String) this.pagePaths.add(path); - }); + pageCount = result["pageCount"]; + pagePaths = []; + for (var path in (result["pagePaths"] as List)) { + if (path is String) pagePaths.add(path); + } } } class FlutterPdfSplit { - static const MethodChannel _channel = const MethodChannel('flutter_pdf_split'); + static const MethodChannel _channel = MethodChannel('flutter_pdf_split'); static Future get platformVersion async { final String? version = await _channel.invokeMethod('getPlatformVersion'); @@ -46,13 +47,13 @@ class FlutterPdfSplit { } static Future split(FlutterPdfSplitArgs args) async { - // TODO verify args keys return _split(args); } /// Splits PDF file [value] and returns the page count. static Future _split(FlutterPdfSplitArgs args) async { - Map result = await (_channel.invokeMethod('split', args.toMap)); + Map result = + await (_channel.invokeMethod('split', args.toMap)); return FlutterPdfSplitResult(result); } } diff --git a/lib/widget/button/button_elevated_widget.dart b/lib/widget/button/button_elevated_widget.dart index e2ac23f..379f095 100644 --- a/lib/widget/button/button_elevated_widget.dart +++ b/lib/widget/button/button_elevated_widget.dart @@ -17,11 +17,11 @@ class ButtonElevatedWidget extends StatelessWidget { Widget build(BuildContext context) { return ElevatedButton( onPressed: onPressed, + style: ElevatedButton.styleFrom(backgroundColor: backgroundColor), child: Text( title, style: TextStyle(color: color, fontSize: fontSize), ), - style: ElevatedButton.styleFrom(backgroundColor: backgroundColor), ); } } diff --git a/lib/widget/gambar.dart b/lib/widget/gambar.dart index b2cf3a4..203d1bb 100644 --- a/lib/widget/gambar.dart +++ b/lib/widget/gambar.dart @@ -1,3 +1,4 @@ +// ignore: camel_case_types class gambar { static String profil = "assets/selvi2.jpeg"; static String logo = "assets/logo2.png"; diff --git a/lib/widget/textfield/textfield_component.dart b/lib/widget/textfield/textfield_component.dart index 0270606..7cdc31c 100644 --- a/lib/widget/textfield/textfield_component.dart +++ b/lib/widget/textfield/textfield_component.dart @@ -17,7 +17,7 @@ class InputTextfield extends StatelessWidget { return TextField( controller: controller, decoration: InputDecoration( - border: OutlineInputBorder(), + border: const OutlineInputBorder(), hintText: hintText, ), ); @@ -53,7 +53,7 @@ class _PasswordTextfieldState extends State { obscureText: passwordVisible, controller: widget.controller, decoration: InputDecoration( - border: OutlineInputBorder(), + border: const OutlineInputBorder(), hintText: widget.hintText, suffixIcon: IconButton( icon: Icon(passwordVisible ? Icons.visibility : Icons.visibility_off), diff --git a/task.txt b/task.txt index 45a50c5..9067be3 100644 --- a/task.txt +++ b/task.txt @@ -1,5 +1,5 @@ version: v0.0.4 ✅ ❌ 🔥 -- tambahkan stok buku 🔥 +- tambahkan stok buku ✅ - tambahkan login ✅ - tambahkan menu tamu ✅