From 6ad354c736867b45c655ac50785ed80a7029a1b9 Mon Sep 17 00:00:00 2001 From: Daffa Ilhami Date: Wed, 30 Nov 2022 22:35:48 +0800 Subject: [PATCH] Fix bug & finising --- .../pages/beranda/pages/barang/barang.dart | 2 +- .../home/pages/beranda/pages/jasa/jasa.dart | 2 +- .../pages/favorit/pages/barang/barang.dart | 108 +++++++++--------- .../pages/edit_produk/edit_produk.dart | 2 + lib/widgets/produk_card.dart | 1 + 5 files changed, 62 insertions(+), 53 deletions(-) diff --git a/lib/pages/home/pages/beranda/pages/barang/barang.dart b/lib/pages/home/pages/beranda/pages/barang/barang.dart index 3949129..913fd34 100644 --- a/lib/pages/home/pages/beranda/pages/barang/barang.dart +++ b/lib/pages/home/pages/beranda/pages/barang/barang.dart @@ -27,7 +27,7 @@ class _MyBarangPageState extends State { children: [ const MyBanner( imageAsset: 'assets/barang-page-banner.jpg', - text: 'Kami menyediakan berbagai barang yang layak untuk anda!', + text: 'Kami menyediakan berbagai barang dan jasa', ), const SizedBox(height: 12), Text( diff --git a/lib/pages/home/pages/beranda/pages/jasa/jasa.dart b/lib/pages/home/pages/beranda/pages/jasa/jasa.dart index 51284ff..b8538d0 100644 --- a/lib/pages/home/pages/beranda/pages/jasa/jasa.dart +++ b/lib/pages/home/pages/beranda/pages/jasa/jasa.dart @@ -27,7 +27,7 @@ class _MyJasaPageState extends State { children: [ const MyBanner( imageAsset: 'assets/jasa-page-banner.jpg', - text: 'Kami menyediakan berbagai jasa yang layak untuk anda!', + text: 'Kami menyediakan berbagai barang dan jasa', ), const SizedBox(height: 12), Text( diff --git a/lib/pages/home/pages/favorit/pages/barang/barang.dart b/lib/pages/home/pages/favorit/pages/barang/barang.dart index bfefab5..b5c3b20 100644 --- a/lib/pages/home/pages/favorit/pages/barang/barang.dart +++ b/lib/pages/home/pages/favorit/pages/barang/barang.dart @@ -52,64 +52,70 @@ class _MyBarangPageState extends State { ), ), const SizedBox(height: 4), - Column( - children: [ - Center( - child: FutureBuilder( - future: selectedKategoriIndex == -1 - ? Pengguna.getBarangFavorit() - : Pengguna.getBarangFavorit( - kategori: - KategoriBarang.values[selectedKategoriIndex], - ), - builder: (context, snapshot) { - if (snapshot.hasError) { - return const Center( - child: Text('Gagal memuat produk!')); - } + SizedBox( + width: double.infinity, + child: Column( + children: [ + Center( + child: FutureBuilder( + future: selectedKategoriIndex == -1 + ? Pengguna.getBarangFavorit() + : Pengguna.getBarangFavorit( + kategori: + KategoriBarang.values[selectedKategoriIndex], + ), + builder: (context, snapshot) { + if (snapshot.hasError) { + return const Center( + child: Text('Gagal memuat produk!')); + } - if (snapshot.connectionState == ConnectionState.waiting) { - return const Padding( - padding: EdgeInsets.only(top: 50), - child: Center(child: CircularProgressIndicator()), - ); - } + if (snapshot.connectionState == + ConnectionState.waiting) { + return const Padding( + padding: EdgeInsets.only(top: 50), + child: Center(child: CircularProgressIndicator()), + ); + } - final List? barang = snapshot.data; + final List? barang = snapshot.data; - return Wrap( - children: List.generate( - barang!.length, - (int i) { - return FutureBuilder( - future: Pengguna.getById(barang[i].idPengguna), - builder: (context, snapshot) { - if (snapshot.hasError) { - return const Center( - child: Text('Gagal memuat produk!')); - } + return Wrap( + alignment: WrapAlignment.start, + runAlignment: WrapAlignment.start, + children: List.generate( + barang!.length, + (int i) { + return FutureBuilder( + future: Pengguna.getById(barang[i].idPengguna), + builder: (context, snapshot) { + if (snapshot.hasError) { + return const Center( + child: Text('Gagal memuat produk!')); + } - if (snapshot.connectionState == - ConnectionState.waiting) { - return const SizedBox.shrink(); - } + if (snapshot.connectionState == + ConnectionState.waiting) { + return const SizedBox.shrink(); + } - final pemilik = snapshot.data!; + final pemilik = snapshot.data!; - return MyProdukCard( - jenisProduk: JenisProduk.barang, - produk: barang[i], - pemilik: pemilik, - ); - }, - ); - }, - ), - ); - }, + return MyProdukCard( + jenisProduk: JenisProduk.barang, + produk: barang[i], + pemilik: pemilik, + ); + }, + ); + }, + ), + ); + }, + ), ), - ), - ], + ], + ), ), ], ), diff --git a/lib/pages/home/pages/marketku/pages/edit_produk/edit_produk.dart b/lib/pages/home/pages/marketku/pages/edit_produk/edit_produk.dart index d760779..226a2fd 100644 --- a/lib/pages/home/pages/marketku/pages/edit_produk/edit_produk.dart +++ b/lib/pages/home/pages/marketku/pages/edit_produk/edit_produk.dart @@ -106,6 +106,7 @@ class _MyEditProdukPageState extends State { pengguna! .addProduk( Barang( + id: widget.produk.id, idPengguna: pengguna.id, urlFoto: urlFoto, nama: nama, @@ -119,6 +120,7 @@ class _MyEditProdukPageState extends State { pengguna! .addProduk( Jasa( + id: widget.produk.id, idPengguna: pengguna.id, urlFoto: urlFoto, nama: nama, diff --git a/lib/widgets/produk_card.dart b/lib/widgets/produk_card.dart index f772ae0..268bacb 100644 --- a/lib/widgets/produk_card.dart +++ b/lib/widgets/produk_card.dart @@ -57,6 +57,7 @@ class MyProdukCard extends StatelessWidget { children: [ Expanded( child: Stack( + fit: StackFit.expand, children: [ Image.network( produk.urlFoto,