Skip to content

Commit

Permalink
task: working on product details screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Atuoha committed Oct 6, 2022
1 parent fa0fc33 commit f863654
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 69 deletions.
143 changes: 76 additions & 67 deletions lib/utilities/k_stream_builder.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:multivendor_shop/views/main/product/details.dart';
import '../components/loading.dart';
import '../constants/colors.dart';

Expand Down Expand Up @@ -75,87 +76,95 @@ class KStreamBuilder extends StatelessWidget {
var data = snapshot.data!.docs[index];
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Container(
// height: 150,
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
child: GestureDetector(
onTap: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => DetailsScreen(
productId: data.id,
),
),
),
child: Stack(
children: [
Card(
elevation: 1.5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
child: Container(
height: 160,
decoration: BoxDecoration(
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),
image: DecorationImage(
image: NetworkImage(data['images'][0]),
fit: BoxFit.cover,
),
child: Container(
height: 160,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: NetworkImage(data['images'][0]),
fit: BoxFit.cover,
),
),
),
),
),
Positioned(
bottom: 4,
left: 5,
child: Text(
data['title'],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: primaryColor,
Positioned(
bottom: 4,
left: 5,
child: Text(
data['title'],
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: primaryColor,
),
),
),
),
Positioned(
bottom: 4,
right: 5,
child: Text(
'\$${data['price']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: primaryColor,
Positioned(
bottom: 4,
right: 5,
child: Text(
'\$${data['price']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: primaryColor,
),
),
),
),
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,
),
),
),
),
)
],
)
],
),
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/views/main/categories/other.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class OtherCategories extends StatelessWidget {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
var imageLocation = 'assets/images/sub_categories/other/';
var imageLocation = 'assets/images/sub_categories/others/';
var category = 'Other';

final categories = [
Expand Down
1 change: 0 additions & 1 deletion lib/views/main/customer/home.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:multivendor_shop/constants/colors.dart';
import '../product_categories/children.dart';
import '../product_categories/men.dart';
import '../product_categories/others.dart';
Expand Down
69 changes: 69 additions & 0 deletions lib/views/main/product/details.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../constants/colors.dart';

class DetailsScreen extends StatefulWidget {
const DetailsScreen({
Key? key,
required this.productId,
}) : super(key: key);
final String productId;

@override
State<DetailsScreen> createState() => _DetailsScreenState();
}

class _DetailsScreenState extends State<DetailsScreen> {
var firebase = FirebaseFirestore.instance;
var isInit = true;
var isLoading = true;
var productDetails;

_fetchDetails() {
var details = firebase.collection('products').doc(widget.productId).get();
setState(() {
productDetails = details;
isLoading = false;
isInit = false;
});
}

@override
void initState() {
super.initState();
}

@override
void didChangeDependencies() {
if (isInit) {
_fetchDetails();
}

super.didChangeDependencies();
}

@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
systemNavigationBarColor: litePrimary,
statusBarIconBrightness: Brightness.dark,
systemNavigationBarDividerColor: Colors.grey,
statusBarBrightness: Brightness.dark,
),
);
return Scaffold(
body: Column(
children: [
Container(
height: size.height / 3,
color:primaryColor,
)
],
),
);
}
}

0 comments on commit f863654

Please sign in to comment.