Skip to content

Commit

Permalink
task: store
Browse files Browse the repository at this point in the history
  • Loading branch information
Atuoha committed Oct 7, 2022
1 parent 17b741f commit 42b3947
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 73 deletions.
121 changes: 65 additions & 56 deletions lib/views/main/product/details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DetailsScreen extends StatefulWidget {
class _DetailsScreenState extends State<DetailsScreen> {
void showImageBottom() {
showModalBottomSheet(
shape: const RoundedRectangleBorder(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
topLeft: Radius.circular(10),
Expand Down Expand Up @@ -278,69 +278,78 @@ class _DetailsScreenState extends State<DetailsScreen> {
var data = snapshot.data!.docs[index];
return Padding(
padding: const EdgeInsets.only(right: 10.0),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
child: GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DetailsScreen(
product: data,
),
),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Column(
children: [
Stack(children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
data['images'][0],
width: 173,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Column(
children: [
Stack(children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Image.network(
data['images'][0],
width: 173,
),
),
),
Positioned(
top: 10,
right: 10,
child: GestureDetector(
onTap: () =>
toggleIsFav(data['isFav'], data.id),
child: CircleAvatar(
backgroundColor: litePrimary,
child: Icon(
data['isFav']
? Icons.favorite
: Icons.favorite_border,
color: Colors.redAccent,
Positioned(
top: 10,
right: 10,
child: GestureDetector(
onTap: () => toggleIsFav(
data['isFav'], data.id),
child: CircleAvatar(
backgroundColor: litePrimary,
child: Icon(
data['isFav']
? Icons.favorite
: Icons.favorite_border,
color: Colors.redAccent,
),
),
),
),
),
Positioned(
top: 10,
left: 10,
child: GestureDetector(
onTap: () => addToCart(),
child: CircleAvatar(
backgroundColor: litePrimary,
child: const Icon(
Icons.shopping_cart_outlined,
color: Colors.white,
Positioned(
top: 10,
left: 10,
child: GestureDetector(
onTap: () => addToCart(),
child: CircleAvatar(
backgroundColor: litePrimary,
child: const Icon(
Icons.shopping_cart_outlined,
color: Colors.white,
),
),
),
),
)
]),
const SizedBox(height: 10),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
data['title'],
style: const TextStyle(
fontWeight: FontWeight.w600,
)
]),
const SizedBox(height: 10),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
data['title'],
style: const TextStyle(
fontWeight: FontWeight.w600,
),
),
),
Text('\$${data['price']}')
],
)
],
Text('\$${data['price']}')
],
)
],
),
),
),
));
Expand Down
4 changes: 2 additions & 2 deletions lib/views/main/seller/seller_bottomNav.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'dashboard.dart';
import 'home.dart';
import 'profile.dart';
import 'category.dart';
import 'shop.dart';
import 'store.dart';

class SellerBottomNav extends StatefulWidget {
static const routeName = '/seller-home';
Expand All @@ -23,7 +23,7 @@ class _SellerBottomNavState extends State<SellerBottomNav> {
const HomeScreen(),
DashboardScreen(),
const CategoryScreen(),
const ShopScreen(),
const StoreScreen(),
const ProfileScreen(),
];

Expand Down
15 changes: 0 additions & 15 deletions lib/views/main/seller/shop.dart

This file was deleted.

167 changes: 167 additions & 0 deletions lib/views/main/seller/store.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import '../../../components/loading.dart';
import '../../../constants/colors.dart';

class StoreScreen extends StatefulWidget {
const StoreScreen({Key? key}) : super(key: key);

@override
State<StoreScreen> createState() => _StoreScreenState();
}

class _StoreScreenState extends State<StoreScreen> {
final Stream<QuerySnapshot> storeStream =
FirebaseFirestore.instance.collection('sellers').snapshots();

@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Padding(
padding: const EdgeInsets.only(top: 48.0),
child: Column(
children: [
Center(
child: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: const [
Icon(
Icons.storefront_rounded,
color: primaryColor,
),
Text(
'Store',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 28,
color: primaryColor,
),
),
],
),
),
const SizedBox(height:10),
SizedBox(
height: size.height / 1.25,
child: StreamBuilder<QuerySnapshot>(
stream: storeStream,
builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return const Center(
child: Text('An error occurred ): '),
);
}

if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(
child: Loading(
color: primaryColor,
kSize: 30,
),
);
}

if (snapshot.data!.docs.isEmpty) {
return Column(
children: [
Image.asset(
'assets/images/sad.png',
width: 150,
),
const SizedBox(height: 10),
const Text(
'No store available!',
style: TextStyle(
color: primaryColor,
),
)
],
);
}

return GridView.builder(
padding: EdgeInsets.zero,
itemCount: snapshot.data!.docs.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 15,
crossAxisSpacing: 2,
),
itemBuilder: (context, index) {
var data = snapshot.data!.docs[index];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: GestureDetector(
// onTap: () => Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) => DetailsScreen(
// product: data,
// ),
// ),
// ),
child: Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: Stack(
children: [
Card(
elevation: 1.5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Container(
height: 160,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(data['image']),
fit: BoxFit.cover,
),
),
),
),
Positioned(
bottom: 4,
left: 5,
child: Text(
data['fullname'],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: primaryColor,
),
),
),
Positioned(
top: 10,
right: 10,
child: GestureDetector(
onTap: () => {},
child: CircleAvatar(
backgroundColor: litePrimary,
child: const Icon(
Icons.storefront,
color: Colors.white,
),
),
),
),
],
),
),
),
);
},
);
},
),
)
],
),
);
}
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added screenshots/New folder/product_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 42b3947

Please sign in to comment.