Skip to content

Commit

Permalink
task: adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Atuoha committed Oct 10, 2022
1 parent 7fccea8 commit eeab18b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 33 deletions.
12 changes: 6 additions & 6 deletions lib/views/main/customer/edit_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class _EditProfileState extends State<EditProfile> {
final _auth = FirebaseAuth.instance;
final firebase = FirebaseFirestore.instance;
var userId = FirebaseAuth.instance.currentUser!.uid;
var credential;
DocumentSnapshot? credential;
var isLoading = true;
var isInit = true;
var changePassword = false;

// fetch user credentials
_fetchUserDetails() async {
credential = await firebase.collection('customers').doc(userId).get();
_emailController.text = credential['email'];
_fullnameController.text = credential['fullname'];
_phoneController.text = credential['phone'];
_addressController.text = credential['address'];
_emailController.text = credential!['email'];
_fullnameController.text = credential!['fullname'];
_phoneController.text = credential!['phone'];
_addressController.text = credential!['address'];
setState(() {
isLoading = false;
});
Expand Down Expand Up @@ -322,7 +322,7 @@ class _EditProfileState extends State<EditProfile> {
: ProfileImagePicker(
selectImage: _selectPhoto,
isReg: false,
imgUrl: credential['image'],
imgUrl: credential!['image'],
),
const SizedBox(height: 10),
Center(
Expand Down
20 changes: 10 additions & 10 deletions lib/views/main/customer/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
var firebase = FirebaseFirestore.instance;
var auth = FirebaseAuth.instance;
var userId = FirebaseAuth.instance.currentUser!.uid;
var credential;
DocumentSnapshot? credential;
var isLoading = true;
var isInit = true;

Expand Down Expand Up @@ -182,12 +182,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
radius: 20,
backgroundColor: primaryColor,
backgroundImage: NetworkImage(
credential['image'],
credential!['image'],
),
),
const SizedBox(width: 10),
Text(
credential['fullname'],
credential!['fullname'],
style: const TextStyle(
fontSize: 12,
color: Colors.white,
Expand All @@ -214,11 +214,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
radius: 65,
backgroundColor: primaryColor,
backgroundImage: NetworkImage(
credential['image'],
credential!['image'],
),
),
Text(
credential['fullname'],
credential!['fullname'],
style: const TextStyle(
fontSize: 18,
color: Colors.white,
Expand Down Expand Up @@ -335,7 +335,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
children: [
KListTile(
title: 'Email Address',
subtitle: credential['email'],
subtitle: credential!['email'],
icon: Icons.email,
),
const Padding(
Expand All @@ -344,9 +344,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
KListTile(
title: 'Phone Number',
subtitle: credential['phone'] == ""
subtitle: credential!['phone'] == ""
? 'Not set yet'
: credential['phone'],
: credential!['phone'],
icon: Icons.phone,
),
const Padding(
Expand All @@ -355,9 +355,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
KListTile(
title: 'Delivery Address',
subtitle: credential['address'] == ""
subtitle: credential!['address'] == ""
? 'Not set yet'
: credential['address'],
: credential!['address'],
icon: Icons.location_pin,
),
],
Expand Down
24 changes: 23 additions & 1 deletion lib/views/main/product/details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:multivendor_shop/components/loading.dart';
import 'package:multivendor_shop/views/main/store/store_details.dart';
import '../../../constants/colors.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';
import 'package:photo_view/photo_view.dart';
Expand Down Expand Up @@ -77,13 +78,31 @@ class _DetailsScreenState extends State<DetailsScreen>
});
}

DocumentSnapshot? store;

_fetchStore() async {
var details = await FirebaseFirestore.instance
.collection('sellers')
.doc(widget.product['seller_id'])
.get();
setState(() {
store = details;
});
}

// add to cart
void addToCart() {
// TODO: Implement add to cart
}

// navigate to store
void navigateToStore() {}
void navigateToStore() {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => StoreDetails(store: store),
),
);
}

Animation<double>? _animation;
AnimationController? _animationController;
Expand All @@ -107,6 +126,9 @@ class _DetailsScreenState extends State<DetailsScreen>
parent: _animationController!,
);
_animation = Tween<double>(begin: 0, end: 1).animate(curvedAnimation);

// fetching store details
_fetchStore();
}
setState(() {
isInit = false;
Expand Down
12 changes: 6 additions & 6 deletions lib/views/main/seller/edit_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ class _EditProfileState extends State<EditProfile> {
final _auth = FirebaseAuth.instance;
final firebase = FirebaseFirestore.instance;
var userId = FirebaseAuth.instance.currentUser!.uid;
var credential;
DocumentSnapshot? credential;
var isLoading = true;
var isInit = true;
var changePassword = false;

// fetch user credentials
_fetchUserDetails() async {
credential = await firebase.collection('sellers').doc(userId).get();
_emailController.text = credential['email'];
_fullnameController.text = credential['fullname'];
_phoneController.text = credential['phone'];
_addressController.text = credential['address'];
_emailController.text = credential!['email'];
_fullnameController.text = credential!['fullname'];
_phoneController.text = credential!['phone'];
_addressController.text = credential!['address'];
setState(() {
isLoading = false;
});
Expand Down Expand Up @@ -322,7 +322,7 @@ class _EditProfileState extends State<EditProfile> {
: ProfileImagePicker(
selectImage: _selectPhoto,
isReg: false,
imgUrl: credential['image'],
imgUrl: credential!['image'],
),
const SizedBox(height: 10),
Center(
Expand Down
20 changes: 10 additions & 10 deletions lib/views/main/seller/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
var firebase = FirebaseFirestore.instance;
var auth = FirebaseAuth.instance;
var userId = FirebaseAuth.instance.currentUser!.uid;
var credential;
DocumentSnapshot? credential;
var isLoading = true;
var isInit = true;

Expand Down Expand Up @@ -181,12 +181,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
radius: 20,
backgroundColor: primaryColor,
backgroundImage: NetworkImage(
credential['image'],
credential!['image'],
),
),
const SizedBox(width: 10),
Text(
credential['fullname'],
credential!['fullname'],
style: const TextStyle(
fontSize: 12,
color: Colors.white,
Expand All @@ -213,11 +213,11 @@ class _ProfileScreenState extends State<ProfileScreen> {
radius: 65,
backgroundColor: primaryColor,
backgroundImage: NetworkImage(
credential['image'],
credential!['image'],
),
),
Text(
credential['fullname'],
credential!['fullname'],
style: const TextStyle(
fontSize: 18,
color: Colors.white,
Expand Down Expand Up @@ -334,7 +334,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
children: [
KListTile(
title: 'Email Address',
subtitle: credential['email'],
subtitle: credential!['email'],
icon: Icons.email,
),
const Padding(
Expand All @@ -343,9 +343,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
KListTile(
title: 'Phone Number',
subtitle: credential['phone'] == ""
subtitle: credential!['phone'] == ""
? 'Not set yet'
: credential['phone'],
: credential!['phone'],
icon: Icons.phone,
),
const Padding(
Expand All @@ -354,9 +354,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
KListTile(
title: 'Delivery Address',
subtitle: credential['address'] == ""
subtitle: credential!['address'] == ""
? 'Not set yet'
: credential['address'],
: credential!['address'],
icon: Icons.location_pin,
),
],
Expand Down

0 comments on commit eeab18b

Please sign in to comment.