Skip to content

Commit

Permalink
Fix bug & finising
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaffailhami committed Nov 30, 2022
1 parent 7abf9df commit 6ad354c
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 53 deletions.
2 changes: 1 addition & 1 deletion lib/pages/home/pages/beranda/pages/barang/barang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _MyBarangPageState extends State<MyBarangPage> {
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(
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/home/pages/beranda/pages/jasa/jasa.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _MyJasaPageState extends State<MyJasaPage> {
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(
Expand Down
108 changes: 57 additions & 51 deletions lib/pages/home/pages/favorit/pages/barang/barang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,64 +52,70 @@ class _MyBarangPageState extends State<MyBarangPage> {
),
),
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>? barang = snapshot.data;
final List<Barang>? 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,
);
},
);
},
),
);
},
),
),
),
],
],
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class _MyEditProdukPageState extends State<MyEditProdukPage> {
pengguna!
.addProduk(
Barang(
id: widget.produk.id,
idPengguna: pengguna.id,
urlFoto: urlFoto,
nama: nama,
Expand All @@ -119,6 +120,7 @@ class _MyEditProdukPageState extends State<MyEditProdukPage> {
pengguna!
.addProduk(
Jasa(
id: widget.produk.id,
idPengguna: pengguna.id,
urlFoto: urlFoto,
nama: nama,
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/produk_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class MyProdukCard extends StatelessWidget {
children: [
Expanded(
child: Stack(
fit: StackFit.expand,
children: [
Image.network(
produk.urlFoto,
Expand Down

0 comments on commit 6ad354c

Please sign in to comment.