repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/flutterzon_provider/lib/features/account
mirrored_repositories/flutterzon_provider/lib/features/account/screens/search_orders_screen.dart
import 'package:amazon_clone_flutter/common/widgets/custom_app_bar.dart'; import 'package:amazon_clone_flutter/features/account/services/account_services.dart'; import 'package:amazon_clone_flutter/features/account/widgets/order_list_single.dart'; import 'package:amazon_clone_flutter/models/order.dart'; import 'package:flutter/material.dart'; class SearchOrderScreeen extends StatefulWidget { static const String routeName = '/search-order-screen'; const SearchOrderScreeen({super.key, required this.orderQuery}); final String orderQuery; @override State<SearchOrderScreeen> createState() => _SearchOrderScreeenState(); } class _SearchOrderScreeenState extends State<SearchOrderScreeen> { final AccountServices accountServices = AccountServices(); List<Order>? ordersList; fetchOrderedProducts() async { ordersList = await accountServices.searchOrder( context: context, searchQuery: widget.orderQuery); setState(() {}); } @override void initState() { super.initState(); fetchOrderedProducts(); } @override Widget build(BuildContext context) { return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar(), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(12.0), child: ordersList == null || ordersList!.isEmpty ? const Center( child: CircularProgressIndicator(), ) : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '${ordersList!.length} order(s) matching "${widget.orderQuery}"', style: const TextStyle(fontSize: 16), ), const SizedBox(height: 10), ListView.builder( itemCount: ordersList!.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: ((context, index) { return OrderListSingle(order: ordersList![index]); }), ), ], ), ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/account
mirrored_repositories/flutterzon_provider/lib/features/account/screens/browsing_history.dart
import 'package:amazon_clone_flutter/common/widgets/custom_app_bar.dart'; import 'package:amazon_clone_flutter/common/widgets/single_listing_product.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../models/product.dart'; class BrowsingHistory extends StatelessWidget { static const String routeName = '/browsing-history'; const BrowsingHistory({super.key}); @override Widget build(BuildContext context) { final userProvider = Provider.of<UserProvider>(context, listen: false); return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar(), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Your Browsing History', style: TextStyle( fontSize: 20, fontWeight: FontWeight.w500, color: Colors.black87), ), userProvider.user.keepShoppingFor.isEmpty ? const Center( child: Text( 'Your browsing history is empty.', style: TextStyle(fontSize: 14, color: Colors.black87), ), ) : Column( children: [ const Text( 'These items were viewed recently, We use them to personalise recommendations.', style: TextStyle( fontSize: 14, fontWeight: FontWeight.normal, color: Colors.black87), ), const SizedBox(height: 10), ListView.builder( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemCount: userProvider.user.keepShoppingFor.length > 40 ? 40 : userProvider.user.keepShoppingFor.length, itemBuilder: ((context, index) { Product product = Product.fromMap(userProvider .user.keepShoppingFor[index]['product']); return SingleListingProduct( product: product, deliveryDate: getDeliveryDate()); })) ], ), ], ), ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/payment_information_block.dart
import 'package:flutter/material.dart'; import '../../../models/user.dart'; class PaymentInformationBlock extends StatelessWidget { const PaymentInformationBlock({ super.key, required this.headingTextSyle, required this.containerDecoration, required this.textSyle, required this.user, }); final TextStyle headingTextSyle; final BoxDecoration containerDecoration; final TextStyle textSyle; final User user; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Payment information', style: headingTextSyle, ), const SizedBox( height: 6, ), Container( width: MediaQuery.sizeOf(context).width, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14), alignment: Alignment.centerLeft, decoration: containerDecoration.copyWith( border: const Border( left: BorderSide(color: Colors.black12, width: 1), right: BorderSide(color: Colors.black12, width: 1), top: BorderSide(color: Colors.black12, width: 1), // bottom: BorderSide(color: Colors.black12, width: 0) ), borderRadius: const BorderRadius.only( topLeft: Radius.circular(5), topRight: Radius.circular(5)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Payment Method', style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.w600), ), Text( 'Google Pay', style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.normal, ), ), ], )), Container( width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), decoration: containerDecoration.copyWith( borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Billing Address', style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.w600), ), Text( user.address, style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.normal, ), ), ], ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/order_summary_total.dart.dart
import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; import '../screens/order_details.dart'; class OrderSummaryTotal extends StatelessWidget { const OrderSummaryTotal({ super.key, required this.firstText, required this.secondText, required this.headingTextSyle, required this.widget, }); final TextStyle headingTextSyle; final String firstText; final String secondText; final OrderDetailsScreen widget; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( firstText, style: headingTextSyle, ), Text( secondText, style: headingTextSyle.copyWith( color: GlobalVariables.redColor, ), ) ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/order_summary_block.dart
import 'package:flutter/material.dart'; import '../../../constants/utils.dart'; import '../screens/order_details.dart'; import 'order_summary_row.dart'; import 'order_summary_total.dart.dart'; class OrderSummaryBlock extends StatelessWidget { const OrderSummaryBlock({ super.key, required this.headingTextSyle, required this.containerDecoration, required this.totalQuantity, required this.textSyle, required this.widget, }); final TextStyle headingTextSyle; final BoxDecoration containerDecoration; final int totalQuantity; final TextStyle textSyle; final OrderDetailsScreen widget; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Order Summary', style: headingTextSyle), const SizedBox(height: 6), Container( padding: const EdgeInsets.all(12), width: double.infinity, decoration: containerDecoration, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ OrderSummaryRow( firstText: 'Items:', secondText: totalQuantity.toString(), textSyle: textSyle, widget: widget), OrderSummaryRow( firstText: 'Postage & Packing:', secondText: '₹0', textSyle: textSyle, widget: widget), OrderSummaryRow( firstText: 'Sub total:', secondText: '₹${formatPriceWithDecimal(widget.order.totalPrice)}', textSyle: textSyle, widget: widget), OrderSummaryTotal( firstText: 'Order Total:', secondText: '₹${formatPriceWithDecimal(widget.order.totalPrice)}', headingTextSyle: headingTextSyle, widget: widget), ]), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/standard_delivery_container.dart
import 'package:flutter/material.dart'; class StandardDeliveryContainer extends StatelessWidget { const StandardDeliveryContainer({ super.key, required this.containerDecoration, required this.textSyle, }); final BoxDecoration containerDecoration; final TextStyle textSyle; @override Widget build(BuildContext context) { return Container( width: MediaQuery.sizeOf(context).width, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12), alignment: Alignment.centerLeft, decoration: containerDecoration.copyWith( border: const Border( left: BorderSide(color: Colors.black12, width: 1), right: BorderSide(color: Colors.black12, width: 1), top: BorderSide(color: Colors.black12, width: 1), // bottom: BorderSide(color: Colors.black12, width: 0) ), borderRadius: const BorderRadius.only( topLeft: Radius.circular(5), topRight: Radius.circular(5)), ), child: Text( 'Standard Delivery', style: textSyle, textAlign: TextAlign.justify, ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/you_might_also_like_block.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:flutter/material.dart'; import '../../../common/widgets/you_might_also_like_single.dart'; import '../../../models/product.dart'; class YouMightAlsoLikeBlock extends StatelessWidget { const YouMightAlsoLikeBlock({ super.key, required this.headingTextSyle, required this.categoryProductList, }); final TextStyle headingTextSyle; final List<Product>? categoryProductList; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'You might also like', style: headingTextSyle, ), const SizedBox( height: 10, ), categoryProductList == null ? const Center(child: CircularProgressIndicator()) : SizedBox( height: 250, child: ListView.builder( itemCount: categoryProductList!.length, scrollDirection: Axis.horizontal, itemBuilder: ((context, index) { Product productData = categoryProductList![index]; return categoryProductList == null ? const Center(child: CircularProgressIndicator()) : InkWell( onTap: () { navigateToProductDetails( context: context, product: productData, deliveryDate: 'Null for now'); }, child: YouMightAlsoLikeSingle(product: productData)); })), ) ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/shipping_address_block.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:flutter/material.dart'; import '../../../models/user.dart'; class ShippingAddressBlock extends StatelessWidget { const ShippingAddressBlock({ super.key, required this.headingTextSyle, required this.containerDecoration, required this.user, required this.textSyle, }); final TextStyle headingTextSyle; final BoxDecoration containerDecoration; final User user; final TextStyle textSyle; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Shipping Address', style: headingTextSyle), const SizedBox(height: 6), Container( padding: const EdgeInsets.all(12), width: double.infinity, decoration: containerDecoration, child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( capitalizeFirstLetter(string: user.name), style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.normal, ), ), Text( user.address, style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.normal, ), ) ]), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/order_summary_row.dart
import 'package:flutter/material.dart'; import '../screens/order_details.dart'; class OrderSummaryRow extends StatelessWidget { const OrderSummaryRow({ super.key, required this.firstText, required this.secondText, required this.textSyle, required this.widget, }); final TextStyle textSyle; final String firstText; final String secondText; final OrderDetailsScreen widget; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( firstText, style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.normal, ), ), Text( secondText, style: textSyle.copyWith( color: Colors.black87, fontWeight: FontWeight.normal, ), ) ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/ordered_products.dart
import 'package:flutter/material.dart'; import '../../../constants/utils.dart'; import '../screens/order_details.dart'; class OrderedProducts extends StatelessWidget { const OrderedProducts({ super.key, required this.widget, required this.textSyle, }); final OrderDetailsScreen widget; final TextStyle textSyle; @override Widget build(BuildContext context) { return Column( children: [ for (int i = 0; i < widget.order.products.length; i++) Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { navigateToProductDetails( context: context, product: widget.order.products[i], deliveryDate: getDeliveryDate()); }, child: Row( children: [ Image.network( widget.order.products[i].images[0], height: 110, width: 100, fit: BoxFit.contain, // width: 120, ), const SizedBox(width: 20), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.order.products[i].name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), const SizedBox( height: 8, ), Text('Qty. ${widget.order.quantity[i]}'), ], ), ), const SizedBox(width: 20), Text( '₹${formatPrice(widget.order.products[i].price)}', style: textSyle.copyWith(fontSize: 16), ), ], ), ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/shipment_details_block.dart
import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/order_details/widgets/shipment_details.dart'; import 'package:amazon_clone_flutter/features/order_details/widgets/standard_delivery_container.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import '../../../models/user.dart'; import '../screens/order_details.dart'; class ShipmentDetailsBlock extends StatefulWidget { const ShipmentDetailsBlock({ super.key, required this.containerDecoration, required this.textSyle, required this.user, required this.currentStep, required this.widget, required this.orderedProductRatings, }); final BoxDecoration containerDecoration; final TextStyle textSyle; final User user; final int currentStep; final List<double> orderedProductRatings; final OrderDetailsScreen widget; @override State<ShipmentDetailsBlock> createState() => _ShipmentDetailsBlockState(); } class _ShipmentDetailsBlockState extends State<ShipmentDetailsBlock> { @override Widget build(BuildContext context) { return widget.orderedProductRatings.isEmpty ? const SizedBox() : Column( children: [ StandardDeliveryContainer( containerDecoration: widget.containerDecoration, textSyle: widget.textSyle), Container( width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: widget.containerDecoration.copyWith( borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ widget.user.type == 'user' ? ShipmentStatus( currentStep: widget.currentStep, textSyle: widget.textSyle) : const SizedBox(), const SizedBox(height: 10), Column( children: [ for (int i = 0; i < widget.widget.order.products.length; i++) Column( children: [ Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( onTap: () { navigateToProductDetails( context: context, product: widget.widget.order.products[i], deliveryDate: getDeliveryDate()); }, child: Row( children: [ Image.network( widget .widget.order.products[i].images[0], height: 110, width: 100, fit: BoxFit.contain, // width: 120, ), const SizedBox(width: 20), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( widget.widget.order.products[i] .name, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold), ), const SizedBox( height: 8, ), Text( 'Qty. ${widget.widget.order.quantity[i]}'), ], ), ), const SizedBox(width: 20), Text( '₹${formatPrice(widget.widget.order.products[i].price)}', style: widget.textSyle .copyWith(fontSize: 16), ), ], ), ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ const Text( 'Your rating', style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Colors.black87), ), RatingBar.builder( itemSize: 28, initialRating: widget.orderedProductRatings[i] == -1 ? 0 : widget.orderedProductRatings[i], minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, itemPadding: const EdgeInsets.symmetric( horizontal: 4), itemBuilder: (context, _) => const Icon( Icons.star, color: GlobalVariables.secondaryColor, ), onRatingUpdate: (rating) { productDetailsServices.rateProduct( context: context, product: widget.widget.order.products[i], rating: rating); setState(() {}); }, ), ], ), const SizedBox(height: 10) ], ), ], ), const SizedBox(height: 10) ], ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/shipment_details.dart
import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class ShipmentStatus extends StatelessWidget { const ShipmentStatus({ super.key, required this.currentStep, required this.textSyle, }); final int currentStep; final TextStyle textSyle; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ currentStep == 1 || currentStep == 0 ? Text( 'Received', style: textSyle.copyWith( fontSize: 18, fontWeight: FontWeight.bold, color: GlobalVariables.greenColor), ) : currentStep == 2 ? Text( 'Dispatched', style: textSyle.copyWith( fontSize: 18, fontWeight: FontWeight.bold, color: GlobalVariables.greenColor), ) : currentStep == 3 ? Text( 'In Transit', style: textSyle.copyWith( fontSize: 18, fontWeight: FontWeight.bold, color: GlobalVariables.greenColor), ) : Text( 'Delivered', style: textSyle.copyWith( fontSize: 18, fontWeight: FontWeight.bold, color: GlobalVariables.greenColor), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/tracking_details.dart
import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../common/widgets/custom_elevated_button.dart'; import '../../../models/order.dart'; import '../../../providers/user_provider.dart'; import '../../admin/services/admin_services.dart'; class TrackingDetails extends StatefulWidget { const TrackingDetails({ super.key, required this.order, }); final Order order; @override State<TrackingDetails> createState() => _TrackingDetailsState(); } class _TrackingDetailsState extends State<TrackingDetails> { final AdminServices adminServices = AdminServices(); int currentStep = 0; void changeOrderStatus(int status) { adminServices.changeOrderStatus( context: context, order: widget.order, status: status + 1, onSuccess: () { setState(() { currentStep += 1; }); }); debugPrint('onPressed clicked!'); } @override void initState() { super.initState(); currentStep = widget.order.status; } @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context, listen: false).user; return Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Delivery by Amazon', style: TextStyle( fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), ), Text( ' Order ID: ${widget.order.id}', style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black87), ), SizedBox( width: double.infinity, child: Stepper( physics: const NeverScrollableScrollPhysics(), currentStep: currentStep, controlsBuilder: ((context, details) { if (user.type == 'admin') { return CustomElevatedButton( buttonText: 'Done', onPressed: () => changeOrderStatus(details.currentStep)); } return const SizedBox(); }), steps: [ Step( title: const Text('Received'), content: const Text( 'Your order has been received and is currently being processed by the seller.'), isActive: currentStep > 0, state: currentStep > 0 ? StepState.complete : StepState.indexed, ), Step( title: const Text('Dispatched'), content: const Text( 'Your order has been shipped and dispatched.'), isActive: currentStep > 1, state: currentStep > 1 ? StepState.complete : StepState.indexed, ), Step( title: const Text('In Transit'), content: const Text('Your order is currently in transit.'), isActive: currentStep > 2, state: currentStep > 2 ? StepState.complete : StepState.indexed, ), Step( title: const Text('Delivered'), content: const Text('Your order has been delivered.'), isActive: currentStep >= 3, state: currentStep >= 3 ? StepState.complete : StepState.indexed, ), ]), ), ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/widgets/track_update_shipment.dart
import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; import '../../../models/user.dart'; import '../screens/order_details.dart'; import '../screens/tracking_details_sceen.dart'; class TrackUpdateShipment extends StatelessWidget { const TrackUpdateShipment({ super.key, required this.widget, required this.user, required this.textSyle, }); final OrderDetailsScreen widget; final User user; final TextStyle textSyle; @override Widget build(BuildContext context) { return Column( children: [ ListTile( onTap: () { Navigator.pushNamed(context, TrackingDetailsScreen.routeName, arguments: widget.order); }, title: Text( user.type == 'user' ? 'Track shipment' : 'Update shipment (admin)', style: user.type == 'user' ? textSyle : textSyle.copyWith(color: GlobalVariables.greenColor), ), style: ListTileStyle.list, trailing: Icon( Icons.chevron_right_rounded, color: user.type == 'user' ? Colors.black87 : GlobalVariables.greenColor, ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/screens/order_details.dart
import 'package:amazon_clone_flutter/common/widgets/custom_app_bar.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/admin/services/admin_services.dart'; import 'package:amazon_clone_flutter/features/product_details/services/product_details_services.dart'; import 'package:amazon_clone_flutter/features/product_details/widgets/divider_with_sizedbox.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../models/order.dart'; import '../../../models/product.dart'; import '../../home/services/home_services.dart'; import '../widgets/order_summary_block.dart'; import '../widgets/payment_information_block.dart'; import '../widgets/shipment_details_block.dart'; import '../widgets/shipping_address_block.dart'; import '../widgets/track_update_shipment.dart'; import '../widgets/you_might_also_like_block.dart'; class OrderDetailsScreen extends StatefulWidget { static const String routeName = '/order-details'; final Order order; const OrderDetailsScreen({super.key, required this.order}); @override State<OrderDetailsScreen> createState() => _OrderDetailsScreenState(); } class _OrderDetailsScreenState extends State<OrderDetailsScreen> { int currentStep = 0; List<Product>? categoryProductList; int totalQuantity = 0; List<double> orderedProductRatings = []; double userRating = -1; final HomeServices homeServices = HomeServices(); final AdminServices adminServices = AdminServices(); final ProductDetailsServices productDetailsServices = ProductDetailsServices(); int getProductsQuantity() { for (int i = 0; i < widget.order.quantity.length; i++) { totalQuantity += widget.order.quantity[i]; } return totalQuantity; } @override void initState() { super.initState(); getCategoryProducts(); getProductsQuantity(); getProductRating(); currentStep = widget.order.status; } getProductRating() async { for (int i = 0; i < widget.order.products.length; i++) { double tempRating = await productDetailsServices.getRating( context: context, product: widget.order.products[i]); orderedProductRatings.add(tempRating); } setState(() {}); } getCategoryProducts() async { categoryProductList = await homeServices.fetchCategoryProducts( context: context, category: widget.order.products[0].category); setState(() {}); } @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context, listen: false).user; final BoxDecoration containerDecoration = BoxDecoration( border: Border.all(color: Colors.black12), borderRadius: BorderRadius.circular(8)); const TextStyle textSyle = TextStyle( color: Colors.black87, fontWeight: FontWeight.w500, fontSize: 15); const TextStyle headingTextSyle = TextStyle( color: Colors.black87, fontWeight: FontWeight.bold, fontSize: 18); return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar()), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'View order details', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), ), const SizedBox( height: 5, ), Container( height: 90, width: double.infinity, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), decoration: containerDecoration, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( 'Order date ${formatDate(widget.order.orderedAt)}', style: textSyle, ), Text('Order # ${widget.order.id}', style: textSyle), Text( 'Order total ₹${formatPrice(widget.order.totalPrice)}', style: textSyle), ], ), ), ], ), const SizedBox( height: 10, ), const Text('Shipment details', style: headingTextSyle), const SizedBox( height: 6, ), orderedProductRatings.length != widget.order.products.length ? const Center( child: CircularProgressIndicator(), ) : ShipmentDetailsBlock( containerDecoration: containerDecoration, textSyle: textSyle, user: user, currentStep: currentStep, widget: widget, orderedProductRatings: orderedProductRatings, ), TrackUpdateShipment(widget: widget, user: user, textSyle: textSyle), const DividerWithSizedBox( thickness: 1, sB1Height: 0, sB2Height: 0, ), PaymentInformationBlock( headingTextSyle: headingTextSyle, containerDecoration: containerDecoration, textSyle: textSyle, user: user), const SizedBox( height: 8, ), ShippingAddressBlock( headingTextSyle: headingTextSyle, containerDecoration: containerDecoration, user: user, textSyle: textSyle), const SizedBox( height: 8, ), OrderSummaryBlock( headingTextSyle: headingTextSyle, containerDecoration: containerDecoration, totalQuantity: totalQuantity, textSyle: textSyle, widget: widget, ), const SizedBox( height: 20, ), user.type == 'admin' ? const SizedBox() : YouMightAlsoLikeBlock( headingTextSyle: headingTextSyle, categoryProductList: categoryProductList) ], ), )), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/order_details
mirrored_repositories/flutterzon_provider/lib/features/order_details/screens/tracking_details_sceen.dart
import 'package:amazon_clone_flutter/common/widgets/custom_app_bar.dart'; import 'package:amazon_clone_flutter/features/admin/services/admin_services.dart'; import 'package:amazon_clone_flutter/features/order_details/screens/order_details.dart'; import 'package:amazon_clone_flutter/features/order_details/widgets/tracking_details.dart'; import 'package:amazon_clone_flutter/features/product_details/widgets/divider_with_sizedbox.dart'; import 'package:amazon_clone_flutter/models/order.dart'; import 'package:amazon_clone_flutter/models/user.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../constants/global_variables.dart'; import '../../../constants/utils.dart'; import '../../../models/product.dart'; class TrackingDetailsScreen extends StatefulWidget { static const routeName = '/tracking-details'; final Order order; const TrackingDetailsScreen({super.key, required this.order}); @override State<TrackingDetailsScreen> createState() => _TrackingDetailsScreenState(); } class _TrackingDetailsScreenState extends State<TrackingDetailsScreen> { final AdminServices adminServices = AdminServices(); int status = 0; @override void initState() { super.initState(); status = widget.order.status; } final TextStyle textStyle = TextStyle( fontSize: 20, fontWeight: FontWeight.w500, color: GlobalVariables.selectedNavBarColor); final TextStyle subtextStyle = const TextStyle( fontSize: 14, fontWeight: FontWeight.normal, color: Colors.black87); @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context, listen: false).user; return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar()), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ user.type == 'user' ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ DeliveryStatusBlock( status: status, textStyle: textStyle, subtextStyle: subtextStyle, product: widget.order.products[0], widget: widget), const DividerWithSizedBox( thickness: 0.5, ), UserAddressBlock( status: status, user: user, subtextStyle: subtextStyle, widget: widget), const DividerWithSizedBox( thickness: 4, sB1Height: 20, sB2Height: 20, ), const Text( 'Delivery by Amazon', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, color: Colors.black87), ), Text( ' Order ID: ${widget.order.id}', style: const TextStyle( fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black87), ), ], ) : TrackingDetails(order: widget.order), const DividerWithSizedBox( thickness: 4, sB1Height: 20, sB2Height: 15, ), const Text( 'Order Info', style: TextStyle( fontSize: 18, fontWeight: FontWeight.w500, color: Colors.black87), ), const SizedBox(height: 10), const Divider( thickness: 0.5, color: Color(0xffD5D9DA), ), ListTile( onTap: () { Navigator.pushNamed(context, OrderDetailsScreen.routeName, arguments: widget.order); }, title: Text('View order details', style: subtextStyle), style: ListTileStyle.list, trailing: Icon( Icons.chevron_right_rounded, color: user.type == 'user' ? Colors.black87 : GlobalVariables.greenColor, ), ), const Divider( thickness: 0.5, color: Color(0xffD5D9DA), ), const DividerWithSizedBox( thickness: 4, sB1Height: 20, sB2Height: 15, ), ], ), ), ), ); } } class UserAddressBlock extends StatelessWidget { const UserAddressBlock({ super.key, required this.user, required this.status, required this.subtextStyle, required this.widget, }); final User user; final int status; final TextStyle subtextStyle; final TrackingDetailsScreen widget; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8), height: 30, width: 30, color: const Color(0xff4CC2B4), child: Image.network( 'https://cdn-icons-png.flaticon.com/512/18/18442.png', color: Colors.white, ), ), const SizedBox(width: 12), SizedBox( height: 80, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( getStatus(status), style: subtextStyle, ), Text( user.name, style: subtextStyle, ), Text( user.address, style: subtextStyle, ), GestureDetector( onTap: () { showModalBottomSheet( backgroundColor: Colors.white, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.only( topLeft: Radius.circular(0), topRight: Radius.circular(0), ), ), context: context, builder: (context) { return TrackingDetails(order: widget.order); }); }, child: Text( 'See all updates', style: subtextStyle.copyWith( color: GlobalVariables.selectedNavBarColor), ), ) ], ), ), ], ); } } class DeliveryStatusBlock extends StatelessWidget { const DeliveryStatusBlock({ super.key, required this.status, required this.textStyle, required this.product, required this.subtextStyle, required this.widget, }); final int status; final Product product; final TextStyle textStyle; final TextStyle subtextStyle; final TrackingDetailsScreen widget; @override Widget build(BuildContext context) { return Row( children: [ Expanded( flex: 6, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( getStatus(status), style: textStyle, ), Text( getSubStatus(status), style: subtextStyle, ), ], ), ), Expanded( flex: 2, child: GestureDetector( onTap: () { navigateToProductDetails( context: context, product: product, deliveryDate: 'Null for now'); }, child: CachedNetworkImage( imageUrl: widget.order.products[0].images[0], height: 60, width: 60, fit: BoxFit.fitHeight, ), ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/menu
mirrored_repositories/flutterzon_provider/lib/features/menu/widgets/container_clipper.dart
import 'package:flutter/material.dart'; class ContainerClipper extends CustomClipper<Path> { @override Path getClip(Size size) { double width = size.width; double height = size.height; final path = Path(); path.moveTo(0, 100); path.lineTo(0, height); path.lineTo(width, height); path.lineTo(width, 100); path.quadraticBezierTo(width * 0.5, 70, 0, 100); path.close(); return path; } @override bool shouldReclip(covariant CustomClipper<Path> oldClipper) { return false; } }
0
mirrored_repositories/flutterzon_provider/lib/features/menu
mirrored_repositories/flutterzon_provider/lib/features/menu/screens/menu_screen.dart
import 'package:amazon_clone_flutter/common/widgets/custom_app_bar.dart'; import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/account/screens/browsing_history.dart'; import 'package:amazon_clone_flutter/features/account/screens/wish_list_screen.dart'; import 'package:amazon_clone_flutter/features/account/screens/your_orders.dart'; import 'package:amazon_clone_flutter/features/cart/widgets/custom_text_button.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../widgets/container_clipper.dart'; class MenuScreen extends StatelessWidget { static const String routeName = '/menu-screen'; const MenuScreen({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar()), bottomSheet: BottomSheet( onClosing: () {}, constraints: const BoxConstraints(maxHeight: 80, minHeight: 80), builder: ((context) { return Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ CustomTextButton( buttonText: 'Orders', onPressed: () { Navigator.pushNamed(context, YourOrders.routeName); }, isMenuScreenButton: true), CustomTextButton( buttonText: 'History', onPressed: () { Navigator.pushNamed(context, BrowsingHistory.routeName); }, isMenuScreenButton: true), CustomTextButton( buttonText: 'Account', onPressed: () {}, isMenuScreenButton: true), CustomTextButton( buttonText: 'Wish List', onPressed: () { Navigator.pushNamed(context, WishListScreen.routeName); }, isMenuScreenButton: true), ], ); })), body: Container( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10), decoration: const BoxDecoration( gradient: LinearGradient(colors: [ Color(0xff84D8E3), Color(0xffA6E6CE), Color.fromARGB(255, 241, 249, 252), ], stops: [ 0, 0.3, 0.7 ], begin: Alignment.topLeft, end: Alignment.bottomCenter), ), child: GridView.builder( itemCount: GlobalVariables.menuScreenImages.length, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisSpacing: 10, mainAxisSpacing: 10, childAspectRatio: 0.75, crossAxisCount: 3), itemBuilder: ((context, index) { Map<String, String> category = GlobalVariables.menuScreenImages[index]; return MenuCategoryContainer( title: category['title']!, category: category['category']!, imageLink: category['image']!, ); // ); })), ), ); } } class MenuCategoryContainer extends StatelessWidget { const MenuCategoryContainer({ super.key, required this.title, required this.imageLink, required this.category, }); final String title; final String imageLink; final String category; @override Widget build(BuildContext context) { return InkWell( onTap: () => navigateToCategoryPage(context, category), child: Container( height: 170, width: 125, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), boxShadow: [ BoxShadow( color: Colors.grey.shade500.withOpacity(0.35), blurRadius: 3, offset: const Offset(0, 0), spreadRadius: 3) ], border: Border.all(color: Colors.grey.shade500, width: 1), ), child: Stack( children: [ Positioned( bottom: 0, child: ClipPath( clipper: ContainerClipper(), child: Container( height: 170, width: 125, decoration: BoxDecoration( color: const Color.fromARGB(255, 229, 249, 254), borderRadius: BorderRadius.circular(8), ), ), ), ), Positioned( bottom: 4, left: 0, right: 0, child: CachedNetworkImage( imageUrl: imageLink, width: 120, height: 90, fit: BoxFit.contain, ), ), Positioned( left: 12, top: 10, child: SizedBox( width: 100, child: Text( title, maxLines: 3, overflow: TextOverflow.ellipsis, style: const TextStyle( fontWeight: FontWeight.normal, fontSize: 14, ), ), )), ], ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/widgets/product_quality_icons.dart
import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class ProductQualityIcons extends StatelessWidget { const ProductQualityIcons({ super.key, }); @override Widget build(BuildContext context) { return SizedBox( height: 100, child: ListView.builder( itemCount: GlobalVariables.productQualityDetails.length, scrollDirection: Axis.horizontal, itemBuilder: ((context, index) { final iconMapPath = GlobalVariables.productQualityDetails[index]['iconName']!; final titleMapPath = GlobalVariables.productQualityDetails[index]['title']!; return SizedBox( width: 100, child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ Image.asset( 'assets/images/product_quality_icons/$iconMapPath', height: 45, width: 45, ), Text( titleMapPath, textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, maxLines: 3, style: TextStyle( letterSpacing: 0, height: 0, wordSpacing: 0, color: GlobalVariables.selectedNavBarColor, fontSize: 14), ) ], ), ); })), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/widgets/product_features.dart
import 'package:flutter/material.dart'; import '../../../models/product.dart'; class ProductFeatures extends StatelessWidget { const ProductFeatures({ super.key, required this.product, }); final Product product; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Features', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87), ), Text(product.description), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/widgets/divider_with_sizedbox.dart
import 'package:flutter/material.dart'; class DividerWithSizedBox extends StatelessWidget { const DividerWithSizedBox({ super.key, this.sB1Height = 8, this.sB2Height = 8, this.thickness = 2, }); final double sB1Height; final double sB2Height; final double thickness; @override Widget build(BuildContext context) { return Column( children: [ SizedBox(height: sB1Height), Divider( color: const Color(0xffD5D9DA), thickness: thickness, ), SizedBox(height: sB2Height), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/widgets/customer_ratings.dart
import 'package:flutter/material.dart'; import '../../../common/widgets/stars.dart'; import '../../../models/product.dart'; class CustomerReviews extends StatelessWidget { const CustomerReviews({ super.key, required this.averageRating, required this.product, }); final double averageRating; final Product product; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Customer ratings', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87), ), const SizedBox(height: 6), Row( children: [ Stars( rating: averageRating, size: 22, ), const SizedBox(width: 5), Text('${averageRating.toStringAsFixed(1)} out of 5', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black87)), const SizedBox(width: 6), ], ), const SizedBox(height: 6), Text( '${product.rating!.length.toString()} global ratings', style: const TextStyle( color: Colors.black54, fontSize: 16, fontWeight: FontWeight.w500, ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/widgets/you_might_also_like.dart
import 'package:flutter/material.dart'; import '../../../common/widgets/you_might_also_like_single.dart'; import '../../../models/product.dart'; import '../screens/product_details_screen.dart'; class YouMightAlsoLike extends StatelessWidget { const YouMightAlsoLike({ super.key, required this.categoryProductList, required this.deliveryDate, }); final List<Product>? categoryProductList; final String deliveryDate; @override Widget build(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'You might also like', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: Colors.black87), ), const SizedBox(height: 8), categoryProductList == null ? const Center( child: CircularProgressIndicator(), ) : SizedBox( height: 250, child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: categoryProductList!.length, itemBuilder: ((context, index) { Product productData = categoryProductList![index]; return GestureDetector( onTap: () { Navigator.pushNamed( context, ProductDetailsScreen.routeName, arguments: { 'product': productData, 'deliveryDate': deliveryDate, }); }, child: YouMightAlsoLikeSingle(product: productData)); })), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/services/product_details_services.dart
import 'dart:convert'; import 'package:amazon_clone_flutter/constants/error_handling.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; import '../../../constants/global_variables.dart'; import '../../../models/product.dart'; import '../../../models/user.dart'; import '../../../providers/cart_offers_provider.dart'; class ProductDetailsServices { void rateProduct({ required BuildContext context, required Product product, required double rating, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post(Uri.parse("$uri/api/rate-product"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode({'id': product.id!, 'rating': rating})); if (context.mounted) { httpErrorHandle(response: res, context: context, onSuccess: () {}); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } Future<double> getRating( {required BuildContext context, required Product product}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); double rating = -1.0; try { http.Response res = await http.get( Uri.parse("$uri/api/get-product-rating/${product.id}"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, ); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { rating = jsonDecode(res.body).toDouble(); }, ); } } catch (e) { if (context.mounted) { showSnackBar(context, '${e.toString()} from product_services'); } } return rating; } Future<double> getAverageRating( {required BuildContext context, required Product product}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); double averageRating = 0; try { http.Response res = await http.get( Uri.parse("$uri/api/get-ratings-average/${product.id}"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, ); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { if (jsonDecode(res.body) != 0 && jsonDecode(res.body) != null) { averageRating = jsonDecode(res.body).toDouble(); } }); } } catch (e) { if (context.mounted) { showSnackBar( context, '${e.toString()} from product_services -> getAvgRating'); } } return averageRating; } void addToCart( {required BuildContext context, required Product product}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); final category = Provider.of<CartOfferProvider>(context, listen: false); try { http.Response res = await http.post( Uri.parse('$uri/api/add-to-cart'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode({ 'id': product.id!, }), ); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { User user = userProvider.user.copyWith( wishList: jsonDecode(res.body)['wishList'], cart: jsonDecode(res.body)['cart'], keepShoppingFor: jsonDecode(res.body)['keepShoppingFor'], saveForLater: jsonDecode(res.body)['saveForLater'], ); userProvider.setUserFromModel(user); category.setCategory1(product.category.toString()); }, ); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } }
0
mirrored_repositories/flutterzon_provider/lib/features/product_details
mirrored_repositories/flutterzon_provider/lib/features/product_details/screens/product_details_screen.dart
import 'package:amazon_clone_flutter/common/widgets/custom_app_bar.dart'; import 'package:amazon_clone_flutter/features/account/services/account_services.dart'; import 'package:amazon_clone_flutter/features/address/screens/address_screen_buy_now.dart'; import 'package:amazon_clone_flutter/providers/cart_offers_provider.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; import 'package:provider/provider.dart'; import 'package:amazon_clone_flutter/common/widgets/custom_elevated_button.dart'; import 'package:amazon_clone_flutter/common/widgets/stars.dart'; import 'package:amazon_clone_flutter/features/home/widgets/custom_carousel_slider.dart'; import 'package:amazon_clone_flutter/features/product_details/services/product_details_services.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import '../../../constants/global_variables.dart'; import '../../../constants/utils.dart'; import '../../../models/product.dart'; import '../../home/services/home_services.dart'; import '../../home/widgets/dots_indicator.dart'; import '../widgets/customer_ratings.dart'; import '../widgets/divider_with_sizedbox.dart'; import '../widgets/product_features.dart'; import '../widgets/product_quality_icons.dart'; import '../widgets/you_might_also_like.dart'; class ProductDetailsScreen extends StatefulWidget { static const String routeName = '/product-details'; final Map<String, dynamic> arguments; const ProductDetailsScreen({ super.key, required this.arguments, }); @override State<ProductDetailsScreen> createState() => _ProductDetailsScreenState(); } class _ProductDetailsScreenState extends State<ProductDetailsScreen> { final ProductDetailsServices productDetailsServices = ProductDetailsServices(); final AccountServices accountServices = AccountServices(); final CarouselController controller = CarouselController(); final HomeServices homeServices = HomeServices(); List<Product>? categoryProductList; int currentIndex = 0; bool isOrdered = false; double averageRating = 0; double userRating = -1; String? price; String? emi; bool isFilled = false; getCategoryProducts() async { categoryProductList = await homeServices.fetchCategoryProducts( context: context, category: widget.arguments['product'].category); categoryProductList!.shuffle(); setState(() {}); } addKeepShoppingForProduct() { accountServices.keepShoppingFor( context: context, product: widget.arguments['product']); setState(() {}); } getProductRating() async { userRating = await productDetailsServices.getRating( context: context, product: widget.arguments['product']); if (context.mounted) { averageRating = await productDetailsServices.getAverageRating( context: context, product: widget.arguments['product']); } setState(() {}); } @override void initState() { super.initState(); getProductRating(); addKeepShoppingForProduct(); getCategoryProducts(); price = formatPrice(widget.arguments['product'].price); emi = getEmi(widget.arguments['product']); } @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context, listen: false).user; Product product = widget.arguments['product']; String deliveryDate = widget.arguments['deliveryDate']; final cartCategoryOffer = Provider.of<CartOfferProvider>(context, listen: false); bool isFavourite = false; final userProvider = Provider.of<UserProvider>(context, listen: false); String productId = widget.arguments['product'].id; for (int i = 0; i < userProvider.user.wishList.length; i++) { if (productId == userProvider.user.wishList[i]['product']['_id']) { isFavourite = true; break; } } return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar()), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Stack( children: [ const SizedBox(height: 10), CustomCarouselSliderList( onPageChanged: (index, reason) { setState(() { currentIndex = index; }); }, sliderImages: widget.arguments['product'].images), Positioned( bottom: 10, child: Container( height: 40, width: 40, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30)), child: Center( child: isFavourite == true ? InkWell( onTap: () { accountServices.deleteFromWishList( context: context, product: widget.arguments['product']); setState(() { isFavourite = false; }); }, child: const Icon( Icons.favorite, color: Colors.red, size: 30, ), ) : InkWell( onTap: () { accountServices.addToWishList( context: context, product: widget.arguments['product']); setState(() { isFavourite = true; }); }, child: const Icon( Icons.favorite_border, color: Colors.grey, size: 30, ), ), ))) ], ), const SizedBox(height: 10), DotsIndicatorList( controller: controller, current: currentIndex, sliderImages: widget.arguments['product'].images), const SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'Visit the Store', style: TextStyle(color: GlobalVariables.selectedNavBarColor), ), Row( children: [ Text(averageRating.toStringAsFixed(1), style: const TextStyle( fontSize: 12, fontWeight: FontWeight.w400, color: Colors.black87)), const SizedBox(width: 4), Stars(rating: averageRating), const SizedBox(width: 6), Text( widget.arguments['product'].rating!.length.toString(), style: TextStyle( color: GlobalVariables.selectedNavBarColor, fontSize: 12, fontWeight: FontWeight.w400, ), ), ], ) ], ), const SizedBox(height: 10), Text( widget.arguments['product'].name, style: const TextStyle(fontSize: 14, color: Colors.black54), ), ], ), const DividerWithSizedBox(), priceEmi(), const DividerWithSizedBox( sB1Height: 15, ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ RichText( text: TextSpan( text: 'Total: ', style: const TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: Colors.black87, ), children: [ TextSpan( text: '₹$price', style: const TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87, ), ) ]), ), const SizedBox( height: 20, ), RichText( text: TextSpan( text: 'FREE delivery ', style: TextStyle( fontSize: 15, fontWeight: FontWeight.normal, color: GlobalVariables.selectedNavBarColor, ), children: [ TextSpan( text: deliveryDate, style: const TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: Colors.black87, ), ) ]), ), const SizedBox( height: 10, ), Row( children: [ const Icon( Icons.location_on_outlined, size: 18, ), const SizedBox( width: 10, ), user.address == '' ? const SizedBox() : Expanded( child: Text( 'Deliver to ${capitalizeFirstLetter(string: user.name)} - ${user.address}', overflow: TextOverflow.ellipsis, style: TextStyle( fontWeight: FontWeight.normal, color: GlobalVariables.selectedNavBarColor), ), ), ], ), const SizedBox(height: 20), const Text( 'In stock', style: TextStyle( color: GlobalVariables.greenColor, fontSize: 16), ), const SizedBox( height: 10, ), CustomElevatedButton( buttonText: 'Add to Cart', onPressed: () { productDetailsServices.addToCart( context: context, product: widget.arguments['product']); showSnackBar(context, 'Added to cart!'); setState(() {}); cartCategoryOffer.setCategory1( widget.arguments['product'].category.toString()); }), const SizedBox( height: 10, ), CustomElevatedButton( buttonText: 'Buy Now', onPressed: () { Navigator.pushNamed(context, AddressScreenBuyNow.routeName, arguments: product); }, color: GlobalVariables.secondaryColor, ), const SizedBox( height: 15, ), Row( children: [ const Icon( Icons.lock_outline, size: 18, ), const SizedBox( width: 10, ), Text( 'Secure transaction', style: TextStyle( color: GlobalVariables.selectedNavBarColor, fontSize: 15), ) ], ), const SizedBox(height: 10), const Text( 'Gift-wrap available.', style: TextStyle( color: Colors.black87, fontSize: 15, fontWeight: FontWeight.w400), ), const SizedBox(height: 14), InkWell( onTap: () { if (isFavourite == true) { showSnackBar( context, 'This product is already in your wish list'); } else { accountServices.addToWishList( context: context, product: widget.arguments['product']); setState(() { isFavourite = true; }); showSnackBar(context, 'Added to wish list!'); } }, child: Text( 'Add to Wish List', style: TextStyle( color: GlobalVariables.selectedNavBarColor, fontSize: 15), ), ), ], ), const DividerWithSizedBox(), const ProductQualityIcons(), const DividerWithSizedBox( sB1Height: 4, sB2Height: 6, ), ProductFeatures(product: product), const DividerWithSizedBox(), CustomerReviews(averageRating: averageRating, product: product), const DividerWithSizedBox(), userRating == -1 ? const SizedBox() : ratingFromUser(context, product), YouMightAlsoLike( categoryProductList: categoryProductList, deliveryDate: deliveryDate), ]), ), ), ); } Column ratingFromUser(BuildContext context, Product product) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( 'Your star rating!', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87), ), const SizedBox(height: 10), RatingBar.builder( itemSize: 28, initialRating: userRating, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, itemPadding: const EdgeInsets.symmetric(horizontal: 4), itemBuilder: (context, _) => const Icon( Icons.star, color: GlobalVariables.secondaryColor, ), onRatingUpdate: (rating) { productDetailsServices.rateProduct( context: context, product: product, rating: rating); setState(() {}); }), const DividerWithSizedBox(), ], ); } Column priceEmi() { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ const Text( '₹', style: TextStyle( fontSize: 18, color: Colors.black, fontWeight: FontWeight.w400), ), const SizedBox( width: 4, ), Text( price!, style: const TextStyle(fontSize: 32, fontWeight: FontWeight.w400), ), ], ), const SizedBox( height: 10, ), RichText( text: TextSpan( text: 'EMI ', style: const TextStyle( fontSize: 15, fontWeight: FontWeight.bold, color: Colors.black), children: [ TextSpan( text: 'from ₹$emi. No Cost EMI available.', style: const TextStyle( fontSize: 15, fontWeight: FontWeight.normal, color: Colors.black, ), ), TextSpan( text: ' EMI options', style: TextStyle( fontSize: 15, fontWeight: FontWeight.normal, color: GlobalVariables.selectedNavBarColor, ), ), ], ), ), const Text( 'Inclusive of all texes', style: TextStyle( fontSize: 15, fontWeight: FontWeight.normal, color: Colors.black, ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/more
mirrored_repositories/flutterzon_provider/lib/features/more/widgets/custom_bottom_sheet.dart
import 'dart:io'; import 'package:amazon_clone_flutter/features/more/widgets/pay_containers.dart'; import 'package:camera_camera/camera_camera.dart'; import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class CustomBottomSheet extends StatefulWidget { const CustomBottomSheet({ super.key, }); @override State<CustomBottomSheet> createState() => _CustomBottomSheetState(); } class _CustomBottomSheetState extends State<CustomBottomSheet> { final List<File>? photos = []; void openCamera() { Navigator.push( context, MaterialPageRoute( builder: (_) => CameraCamera( onFile: (file) { photos!.add(file); Navigator.pop(context); setState( () {}, ); }, ), ), ); } @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 18).copyWith(bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ const Center( child: Text( 'Do more with Amazon', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500), )), const SizedBox(height: 10), GestureDetector( onTap: () => openCamera(), child: Container( padding: const EdgeInsets.all(16), width: double.infinity, decoration: BoxDecoration( color: const Color(0xffE9EDEE), border: Border.all(color: const Color(0xffD6DADB), width: 0.5), borderRadius: const BorderRadius.only( topLeft: Radius.circular(8), topRight: Radius.circular(8))), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const SizedBox( height: 20, ), const Icon( Icons.center_focus_strong_outlined, size: 50, color: Colors.black54, ), const SizedBox( height: 10, ), Text( 'Tap here to enable your camera', style: TextStyle( fontSize: 12, color: GlobalVariables.selectedNavBarColor), ), ], ), ), ), Container( width: double.infinity, alignment: Alignment.center, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), decoration: BoxDecoration( color: const Color(0xffE2EFE8), border: Border.all(color: const Color(0xffD6DADB), width: 0.5), borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8))), child: const Text( 'Scan any QR to Pay', style: TextStyle(fontSize: 14, fontWeight: FontWeight.normal), ), ), const SizedBox(height: 12), const Row( children: [ PayContainers( imagepath: 'assets/images/bottom_offers/amazon_pay.png', belowText: 'Pay Bills, Send Money & more', onPressedString: 'Amazon Pay'), SizedBox(width: 10), PayContainers( imagepath: 'assets/images/minitv.png', belowText: 'Watch Free Web Series & Shows', onPressedString: 'Amazon MiniTV'), ], ) ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/more
mirrored_repositories/flutterzon_provider/lib/features/more/widgets/pay_containers.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:flutter/material.dart'; class PayContainers extends StatelessWidget { const PayContainers({ super.key, required this.imagepath, required this.belowText, required this.onPressedString, }); final String imagepath; final String belowText; final String onPressedString; @override Widget build(BuildContext context) { return Expanded( child: GestureDetector( onTap: () { if (context.mounted) { showSnackBar(context, '$onPressedString coming soon!'); } }, child: Container( padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 14), decoration: BoxDecoration( boxShadow: const [ BoxShadow( color: Colors.grey, offset: Offset(0, 3), // Adjust shadow offset blurRadius: 3, // Adjust blur radius spreadRadius: 0, // Adjust spread radius ), ], color: const Color(0xffF6FAFB), border: Border.all(color: const Color(0xffD6DADB), width: 0.5), borderRadius: BorderRadius.circular(8), ), child: Column( children: [ Image.asset(imagepath, height: 45), const SizedBox( height: 10, ), Text( belowText, textAlign: TextAlign.center, style: const TextStyle( fontSize: 14, fontWeight: FontWeight.normal, color: Colors.black87), ) ], ), ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/more
mirrored_repositories/flutterzon_provider/lib/features/more/screens/more_screen.dart
import 'package:amazon_clone_flutter/features/account/screens/account_screen.dart'; import 'package:amazon_clone_flutter/features/home/screens/home_screen.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../providers/screen_number_provider.dart'; import '../../cart/screens/cart_screen.dart'; import '../widgets/custom_bottom_sheet.dart'; class MoreScreen extends StatefulWidget { const MoreScreen({ super.key, }); @override State<MoreScreen> createState() => _MoreScreenState(); } class _MoreScreenState extends State<MoreScreen> { @override Widget build(BuildContext context) { final screenNumberProvider = Provider.of<ScreenNumberProvider>(context, listen: false); Widget getScreen({ required int screenNumber, }) { if (screenNumber == 0) { return const HomeScreen(); } else if (screenNumber == 1) { return const AccountScreen(); } else if (screenNumber == 3) { return const CartScreen(); } else if (screenNumber == 4) { return const Scaffold( body: Center( child: Text('Menu Screen'), ), ); } return const HomeScreen(); } return Scaffold(body: Consumer<ScreenNumberProvider>(builder: (context, provider, child) { final isOpen = provider.isOpen; return isOpen == true ? Stack( children: [ getScreen(screenNumber: screenNumberProvider.screenNumber), Container( height: double.infinity, width: double.infinity, color: Colors.black.withOpacity(0.5), ), ], ) : getScreen(screenNumber: screenNumberProvider.screenNumber); }), // : getScreen(screenNumber: screenNumberProvider), bottomSheet: Consumer<ScreenNumberProvider>( builder: ((context, provider, child) { final isOpen = provider.isOpen; return isOpen == true ? BottomSheet( backgroundColor: const Color(0xffffffff), shadowColor: Colors.white, dragHandleColor: const Color(0xffDDDDDD), dragHandleSize: const Size(50, 4), enableDrag: false, showDragHandle: true, constraints: const BoxConstraints(minHeight: 400, maxHeight: 400), onClosing: () {}, builder: (context) { return const CustomBottomSheet(); }, ) : const SizedBox(); }))); } }
0
mirrored_repositories/flutterzon_provider/lib/features/auth
mirrored_repositories/flutterzon_provider/lib/features/auth/services/auth_service.dart
import 'dart:convert'; import 'package:amazon_clone_flutter/constants/error_handling.dart'; import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/admin/screens/bottom_bar.dart'; import 'package:amazon_clone_flutter/features/auth/screens/auth_screen.dart'; import 'package:amazon_clone_flutter/models/user.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../../../common/widgets/bottom_bar.dart'; class AuthService { void signUpUser( {required BuildContext context, required String name, required String email, required String password}) async { try { User user = User( id: '', name: name, email: email, password: password, address: '', type: '', token: '', cart: [], saveForLater: [], keepShoppingFor: [], wishList: [], ); http.Response res = await http.post(Uri.parse('$uri/api/signup'), body: user.toJson(), headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8' }); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { showSnackBar(context, 'Account created! you can login now'); }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } void signInUser( {required BuildContext context, required String email, required String password}) async { try { http.Response res = await http.post(Uri.parse('$uri/api/signin'), body: jsonEncode({ 'email': email, 'password': password, }), headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8' }); debugPrint(res.body); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () async { final SharedPreferences prefs = await SharedPreferences.getInstance(); if (context.mounted) { Provider.of<UserProvider>(context, listen: false) .setUser(res.body); } await prefs.setString( 'x-auth-token', jsonDecode(res.body)['token']); User user = // ignore: use_build_context_synchronously Provider.of<UserProvider>(context, listen: false).user; if (context.mounted) { if (user.type == 'admin') { Navigator.pushNamedAndRemoveUntil( context, AdminScreen.routeName, (route) => false); } else if (user.type == 'user') { Navigator.pushNamedAndRemoveUntil( context, BottomBar.routeName, (route) => false); } else { Navigator.pushNamedAndRemoveUntil( context, AuthScreen.routeName, (route) => false); } showSnackBar(context, 'Sign in success'); } }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } Future<User> getUserData(BuildContext context) async { var userProvider = Provider.of<UserProvider>(context, listen: false); try { SharedPreferences prefs = await SharedPreferences.getInstance(); String? token = prefs.getString('x-auth-token'); if (token == null) { prefs.setString('x-auth-token', ''); } var tokenRes = await http.post(Uri.parse('$uri/tokenIsValid'), headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': token! }); var response = jsonDecode(tokenRes.body); if (response == true) { http.Response userRes = await http.get(Uri.parse('$uri/'), headers: <String, String>{ 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': token }); if (context.mounted) { userProvider.setUser(userRes.body); } } return userProvider.user; } catch (e) { User user = User( id: '', name: '', email: '', password: '', address: '', type: '', token: '', cart: [], saveForLater: [], keepShoppingFor: [], wishList: []); return user; } } }
0
mirrored_repositories/flutterzon_provider/lib/features/auth
mirrored_repositories/flutterzon_provider/lib/features/auth/screens/auth_screen.dart
import 'package:amazon_clone_flutter/common/widgets/custom_textfield.dart'; import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/auth/services/auth_service.dart'; import 'package:flutter/material.dart'; import '../../../common/widgets/custom_elevated_button.dart'; enum Auth { signIn, signUp } class AuthScreen extends StatefulWidget { static const String routeName = 'auth-screen'; const AuthScreen({super.key}); @override State<AuthScreen> createState() => _AuthScreenState(); } class _AuthScreenState extends State<AuthScreen> { Auth _auth = Auth.signUp; final _signUpFormKey = GlobalKey<FormState>(); final _signInFormKey = GlobalKey<FormState>(); final AuthService authService = AuthService(); bool isLoading = false; final TextEditingController _emailController = TextEditingController(); final TextEditingController _passwordController = TextEditingController(); final TextEditingController _nameController = TextEditingController(); @override void dispose() { super.dispose(); _emailController.dispose(); _passwordController.dispose(); _nameController.dispose(); } void signUpUser() { authService.signUpUser( context: context, name: _nameController.text, email: _emailController.text, password: _passwordController.text); setState(() { isLoading = false; }); } void signInUser() { authService.signInUser( context: context, email: _emailController.text, password: _passwordController.text); setState(() { isLoading = false; }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: GlobalVariables.greyBackgroundColor, body: isLoading ? SizedBox( height: MediaQuery.sizeOf(context).height, child: const Center( child: CircularProgressIndicator(), ), ) : SafeArea( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Image.asset( 'assets/images/amazon_in.png', height: 40, width: 50, ), const SizedBox.square( dimension: 12, ), const Text( 'Welcome', style: TextStyle( fontSize: 22, fontWeight: FontWeight.w400), ), const SizedBox.square( dimension: 12, ), // Sign Up Section Container( padding: const EdgeInsets.only( bottom: 10, right: 8, left: 8), decoration: BoxDecoration( color: _auth == Auth.signUp ? GlobalVariables.backgroundColor : GlobalVariables.greyBackgroundColor, borderRadius: BorderRadius.circular(6), ), child: Column( children: [ ListTile( minLeadingWidth: 2, leading: SizedBox.square( dimension: 12, child: Radio( value: Auth.signUp, groupValue: _auth, onChanged: (Auth? val) { setState(() { _auth = val!; }); }), ), title: RichText( text: const TextSpan(children: [ TextSpan( text: 'Create account. ', style: TextStyle( fontWeight: FontWeight.w500, fontSize: 17, color: Colors.black), ), TextSpan( text: 'New to Amazon?', style: TextStyle( fontSize: 13, color: Colors.black87), ) ]), ), onTap: () { setState(() { _auth = Auth.signUp; }); }, ), if (_auth == Auth.signUp) Form( key: _signUpFormKey, child: Column( children: [ CustomTextfield( controller: _nameController, hintText: 'First and last name', ), CustomTextfield( controller: _emailController, hintText: 'Email', ), CustomTextfield( controller: _passwordController, hintText: 'Set password', ), Row( children: [ Image.asset( 'assets/images/info_icon.png', height: 15, width: 15, ), const Text( ' Passwords must be at least 6 characters.'), ], ), const SizedBox.square( dimension: 15, ), CustomElevatedButton( buttonText: 'Create account', onPressed: () { if (_signUpFormKey.currentState! .validate()) { isLoading = true; setState(() {}); showSnackBar(context, 'Signing Up, please wait...'); signUpUser(); } }, ) ], ), ), ], ), ), // Sign In Section Container( padding: const EdgeInsets.only( bottom: 10, right: 8, left: 8), decoration: BoxDecoration( color: _auth == Auth.signIn ? GlobalVariables.backgroundColor : GlobalVariables.greyBackgroundColor, borderRadius: BorderRadius.circular(6)), child: Column( children: [ ListTile( minLeadingWidth: 2, leading: SizedBox.square( dimension: 12, child: Radio( value: Auth.signIn, groupValue: _auth, onChanged: (Auth? val) { setState(() { _auth = val!; }); }), ), title: RichText( text: const TextSpan(children: [ TextSpan( text: 'Sign in. ', style: TextStyle( fontWeight: FontWeight.w500, fontSize: 17, color: Colors.black), ), TextSpan( text: 'Already a customer?', style: TextStyle( fontSize: 13, color: Colors.black87), ), ]), ), onTap: () { setState(() { _auth = Auth.signIn; }); }, ), if (_auth == Auth.signIn) Form( key: _signInFormKey, child: Column( children: [ CustomTextfield( controller: _emailController, hintText: 'Email'), CustomTextfield( controller: _passwordController, hintText: 'Password'), const SizedBox.square( dimension: 6, ), CustomElevatedButton( buttonText: 'Continue', onPressed: () { if (_signInFormKey.currentState! .validate()) { isLoading = true; setState(() {}); showSnackBar(context, 'Signing In, please wait...'); signInUser(); } }, ) ], ), ), ], ), ), const SizedBox.square( dimension: 20, ), Divider( color: Colors.grey.shade300, indent: 20, endIndent: 20, thickness: 0.5, ), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ customTextButton(buttonText: 'Conditions of Use'), customTextButton(buttonText: 'Privacy Notice'), customTextButton(buttonText: 'Help'), ]), const Center( child: Text( '© 1996-2023, Amazon.com, Inc. or its affiliates', style: TextStyle(fontSize: 12), ), ), const SizedBox.square( dimension: 20, ), ], ), ), ), ), ); } TextButton customTextButton({String? buttonText}) { return TextButton( onPressed: () {}, child: Text( buttonText!, style: const TextStyle(color: Color(0xff1F72C5), fontSize: 15), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/custom_carousel_slider.dart
import 'package:amazon_clone_flutter/features/home/screens/category_deals_screen.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; class CustomCarouselSliderMap extends StatelessWidget { const CustomCarouselSliderMap( {super.key, required this.onPageChanged, required this.sliderImages}); final List<Map<String, String>> sliderImages; final Function(int p1, CarouselPageChangedReason p2) onPageChanged; @override Widget build(BuildContext context) { return CarouselSlider( items: sliderImages.map((i) { return Builder(builder: (context) { return GestureDetector( onTap: () { Navigator.pushNamed(context, CategoryDealsScreen.routeName, arguments: i['category']); }, child: CachedNetworkImage( imageUrl: i['image']!, fit: BoxFit.contain, alignment: Alignment.topCenter, placeholder: (context, url) => const SizedBox(), errorWidget: (context, url, error) => const Icon(Icons.error), ), ); }); }).toList(), options: CarouselOptions( height: 450, viewportFraction: 1, onPageChanged: onPageChanged), ); } } class CustomCarouselSliderList extends StatelessWidget { const CustomCarouselSliderList({ super.key, required this.sliderImages, required this.onPageChanged, }); final List<String> sliderImages; final Function(int p1, CarouselPageChangedReason p2) onPageChanged; @override Widget build(BuildContext context) { return CarouselSlider( items: sliderImages.map((i) { return Builder(builder: (context) { return CachedNetworkImage( imageUrl: i, fit: BoxFit.contain, alignment: Alignment.topCenter, placeholder: (context, url) => const SizedBox(), errorWidget: (context, url, error) => const Icon(Icons.error), ); }); }).toList(), options: CarouselOptions( height: 450, viewportFraction: 1, onPageChanged: onPageChanged), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/address_bar.dart
import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class AddressBar extends StatelessWidget { const AddressBar({super.key}); @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context).user; return Container( padding: const EdgeInsets.symmetric(horizontal: 12), height: 40, decoration: const BoxDecoration(gradient: GlobalVariables.addressBarGradient), child: Row( children: [ const Icon( Icons.location_on_outlined, size: 20, ), const SizedBox( width: 10, ), Expanded( child: Text( 'Deliver to ${capitalizeFirstLetter(string: user.name)} - ${user.address}', overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.normal), ), ), const Icon( Icons.expand_more, size: 20, ), ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/single_image_offer.dart
import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../screens/category_deals_screen.dart'; class SingleImageOffer extends StatelessWidget { const SingleImageOffer({ super.key, required this.headTitle, required this.subTitle, required this.productCategory, required this.image, }); final String headTitle; final String subTitle; final String image; final String productCategory; @override Widget build(BuildContext context) { void goToCateogryDealsScreen() { Navigator.pushNamed(context, CategoryDealsScreen.routeName, arguments: productCategory); } return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox( height: 12, ), Text( headTitle, style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16), ), Text( subTitle, style: const TextStyle(fontWeight: FontWeight.normal, fontSize: 14), ), const SizedBox( height: 12, ), Container( decoration: BoxDecoration( color: Colors.transparent, borderRadius: BorderRadius.circular(20), ), child: InkWell( onTap: () => goToCateogryDealsScreen(), child: ClipRRect( borderRadius: BorderRadius.circular(5), child: CachedNetworkImage( fit: BoxFit.fill, imageUrl: image, placeholder: (context, url) => const CircularProgressIndicator(), errorWidget: (context, url, error) => const Icon(Icons.error), ), ), ), ), const SizedBox( height: 10, ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/search_text_form_field.dart
import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class SearchTextFormField extends StatelessWidget { SearchTextFormField({super.key, required this.onTapSearchField}); final Function(String)? onTapSearchField; final OutlineInputBorder textFieldStyle = OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: const BorderSide(color: Colors.grey)); @override Widget build(BuildContext context) { return TextFormField( onFieldSubmitted: onTapSearchField, style: const TextStyle(fontWeight: FontWeight.normal, color: Colors.black), cursorColor: GlobalVariables.selectedNavBarColor, decoration: InputDecoration( filled: true, fillColor: Colors.white, hintText: 'Search Amazon.in', hintStyle: const TextStyle( color: Colors.black45, fontWeight: FontWeight.normal), constraints: const BoxConstraints(maxHeight: 45, minHeight: 45), prefixIcon: const Icon(Icons.search), focusedBorder: textFieldStyle, enabledBorder: textFieldStyle, border: textFieldStyle, contentPadding: const EdgeInsets.only(top: 3), suffixIcon: const SizedBox( width: 75, child: Row( children: [ Icon( Icons.center_focus_strong_outlined, color: Colors.grey, ), Spacer(), Icon( Icons.mic_outlined, color: Colors.grey, ), SizedBox( width: 10, ) ], ), ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/deal_of_the_day.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/home/services/home_services.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../../../models/product.dart'; class DealOfTheDay extends StatefulWidget { const DealOfTheDay({super.key}); @override State<DealOfTheDay> createState() => _DealOfTheDayState(); } class _DealOfTheDayState extends State<DealOfTheDay> { Product? product; final HomeServices homeServices = HomeServices(); @override void initState() { super.initState(); fetchDealOfTheDay(); } void fetchDealOfTheDay() async { product = await homeServices.fetchDealOfTheDay(context: context); if (context.mounted) { setState(() {}); } } int imageIndex = 0; @override Widget build(BuildContext context) { return product == null ? const SizedBox() : product!.name.isEmpty ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox( height: 10, ), const Text('Deal of the day', style: TextStyle(fontWeight: FontWeight.w600, fontSize: 16)), const SizedBox( height: 10, ), Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5)), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: GestureDetector( onTap: () { navigateToProductDetails( context: context, product: product!, deliveryDate: getDeliveryDate()); }, child: CachedNetworkImage( fit: BoxFit.fill, imageUrl: product!.images[imageIndex], height: 250, placeholder: (context, url) => const Center( child: CircularProgressIndicator()), errorWidget: (context, url, error) => const Icon(Icons.error), ), ), ), const SizedBox( height: 8, ), Text( product!.name, style: const TextStyle( fontWeight: FontWeight.normal, fontSize: 14), ), SizedBox( height: 120, child: ListView.builder( itemCount: product!.images.length, scrollDirection: Axis.horizontal, itemBuilder: ((context, index) { return GestureDetector( onTap: () { setState(() { imageIndex = index; }); }, child: Padding( padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( color: Colors.grey.shade100, borderRadius: BorderRadius.circular(8)), child: CachedNetworkImage( fit: BoxFit.contain, imageUrl: product!.images[index], height: 70, width: 90, placeholder: (context, url) => const Center( child: CircularProgressIndicator()), errorWidget: (context, url, error) => const Icon(Icons.error), ), ), ), ); }), ), ), ], ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/carousel_image.dart
import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter/material.dart'; import 'background_white_gradient.dart'; import 'bottom_offers.dart'; import 'custom_carousel_slider.dart'; import 'dots_indicator.dart'; class CarouselImage extends StatefulWidget { const CarouselImage({super.key}); @override State<CarouselImage> createState() => _CarouselImageState(); } class _CarouselImageState extends State<CarouselImage> { int _current = 0; final CarouselController _controller = CarouselController(); @override Widget build(BuildContext context) { return Stack( children: [ CustomCarouselSliderMap( sliderImages: GlobalVariables.carouselImages, onPageChanged: (index, reason) { setState(() { _current = index; }); }), Positioned( top: 245, left: MediaQuery.sizeOf(context).width / 3.3, child: DotsIndicatorMap( controller: _controller, current: _current, sliderImages: GlobalVariables.carouselImages, ), ), const Positioned( bottom: 0, child: BackgroundWhiteGradient(), ), const Positioned( bottom: 0, child: BottomOffers(), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/dots_indicator.dart
import 'package:carousel_slider/carousel_controller.dart'; import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class DotsIndicatorMap extends StatelessWidget { const DotsIndicatorMap({ super.key, required this.controller, required this.current, required this.sliderImages, }); final CarouselController controller; final int current; final List<Map<String, String>> sliderImages; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: sliderImages.asMap().entries.map((entry) { return GestureDetector( onTap: () => controller.animateToPage(entry.key), child: Container( width: 9.0, height: 9.0, margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0), decoration: BoxDecoration( border: Border.all(color: Colors.grey), shape: BoxShape.circle, color: current == entry.key ? GlobalVariables.selectedNavBarColor : Colors.white), ), ); }).toList(), ); } } class DotsIndicatorList extends StatelessWidget { const DotsIndicatorList({ super.key, required this.controller, required this.current, required this.sliderImages, }); final CarouselController controller; final int current; final List<String> sliderImages; @override Widget build(BuildContext context) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: sliderImages.asMap().entries.map((entry) { return GestureDetector( onTap: () => controller.animateToPage(entry.key), child: Container( width: 9.0, height: 9.0, margin: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0), decoration: BoxDecoration( border: Border.all(color: Colors.grey), shape: BoxShape.circle, color: current == entry.key ? GlobalVariables.selectedNavBarColor : Colors.white), ), ); }).toList(), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/single_top_category_item.dart
import 'package:flutter/material.dart'; class SingleTopCategoryItem extends StatelessWidget { const SingleTopCategoryItem( {super.key, required this.image, required this.title, this.isBottomOffer = false}); final String image; final String title; final bool isBottomOffer; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.symmetric( horizontal: isBottomOffer ? 0 : 10, ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( image, height: 50, width: 50, fit: BoxFit.cover, ), Text( title, style: isBottomOffer ? const TextStyle(fontSize: 11) : const TextStyle(), ), ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/bottom_offers.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/home/screens/category_deals_screen.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class BottomOffers extends StatelessWidget { const BottomOffers({ super.key, }); @override Widget build(BuildContext context) { return SizedBox( height: 180, width: MediaQuery.sizeOf(context).width, child: ListView.builder( padding: const EdgeInsets.only(left: 4, right: 0), itemCount: GlobalVariables.bottomOfferImages.length, scrollDirection: Axis.horizontal, itemBuilder: ((context, index) { // if (index == 0) { // return const Row( // children: [ // SingleBottomOffer( // mapName: GlobalVariables.bottomOffersAmazonPay, // ), // ], // ); // } else { return Container( padding: const EdgeInsets.symmetric(horizontal: 4), child: InkWell( onTap: () { if (GlobalVariables.bottomOfferImages[index]['category'] == 'AmazonPay') { if (context.mounted) { showSnackBar(context, 'Amazon Pay coming soon!'); } } else { Navigator.pushNamed(context, CategoryDealsScreen.routeName, arguments: GlobalVariables.bottomOfferImages[index] ['category']); } }, child: CachedNetworkImage( imageUrl: GlobalVariables.bottomOfferImages[index]['image']!, placeholder: (context, url) => const SizedBox(), errorWidget: (context, url, error) => const Icon(Icons.error), ), ), ); // } }), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/background_white_gradient.dart
import 'package:flutter/material.dart'; class BackgroundWhiteGradient extends StatelessWidget { const BackgroundWhiteGradient({ super.key, }); @override Widget build(BuildContext context) { return Container( height: 180, width: MediaQuery.sizeOf(context).width, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Colors.white.withOpacity(0.1), Colors.white.withOpacity(0.3), Colors.white.withOpacity(0.95), Colors.white, ], stops: const [0, 0.1, 0.4, 0.6], ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/multi_image_offer.dart
import 'package:amazon_clone_flutter/features/home/screens/category_deals_screen.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class MultiImageOffer extends StatelessWidget { const MultiImageOffer({ super.key, required this.headtitle, required this.subTitle, required this.mapName, required this.productCategory, }); final List<Map<String, String>> mapName; final String headtitle; final String subTitle; final String productCategory; @override Widget build(BuildContext context) { void goToCateogryDealsScreen() { Navigator.pushNamed(context, CategoryDealsScreen.routeName, arguments: productCategory); } return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( headtitle, style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 16), ), Text( subTitle, style: const TextStyle( fontWeight: FontWeight.normal, fontSize: 14), ), ], ), ), Container( height: 500, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(5)), // width: MediaQuery.sizeOf(context).width, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 460, child: GridView.builder( itemCount: 4, physics: const NeverScrollableScrollPhysics(), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( mainAxisExtent: 230, crossAxisCount: 2), itemBuilder: ((context, index) { return InkWell( onTap: () => goToCateogryDealsScreen(), child: Padding( padding: const EdgeInsets.only(left: 6, right: 6, top: 6), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( flex: 5, child: ClipRRect( borderRadius: BorderRadius.circular(5), child: CachedNetworkImage( imageUrl: mapName[index]['image']!, fit: BoxFit.fill, width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height, placeholder: (context, url) => const Center( child: CircularProgressIndicator()), errorWidget: (context, url, error) => const Icon(Icons.error), ), ), ), Expanded( flex: 1, child: Text( mapName[index]['offerTitle']!, overflow: TextOverflow.ellipsis, maxLines: 2, ), ), ], ), ), ); }), ), ), Padding( padding: const EdgeInsets.only(top: 10, left: 8), child: GestureDetector( onTap: () => goToCateogryDealsScreen(), child: Text( 'See all offers', style: TextStyle(color: GlobalVariables.selectedNavBarColor), ), ), ) ], ), ), ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/top_categories.dart
import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:flutter/material.dart'; import '../../../constants/utils.dart'; import 'single_top_category_item.dart'; class TopCategories extends StatelessWidget { const TopCategories({super.key}); @override Widget build(BuildContext context) { return Container( height: 90, decoration: const BoxDecoration(gradient: GlobalVariables.goldenGradient), child: Center( child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: GlobalVariables.categoryImages.length, itemBuilder: (context, index) { return GestureDetector( onTap: () => navigateToCategoryPage( context, GlobalVariables.categoryImages[index]['title']!), child: SingleTopCategoryItem( title: GlobalVariables.categoryImages[index]['title']!, image: GlobalVariables.categoryImages[index]['image']!, ), ); }), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/widgets/single_bottom_offer.dart
import 'package:amazon_clone_flutter/features/home/widgets/single_top_category_item.dart'; import 'package:flutter/material.dart'; import '../../../constants/global_variables.dart'; class SingleBottomOffer extends StatelessWidget { const SingleBottomOffer({ super.key, required this.mapName, }); final dynamic mapName; @override Widget build(BuildContext context) { return Container( margin: const EdgeInsets.only(left: 4, right: 4), padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4), width: 150, decoration: BoxDecoration( gradient: GlobalVariables.goldenGradient, borderRadius: BorderRadius.circular(4), ), child: GridView.builder( physics: const NeverScrollableScrollPhysics(), itemCount: 4, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( mainAxisExtent: 85, crossAxisCount: 2), itemBuilder: (context, index) { return SingleTopCategoryItem( image: mapName[index]['image']!, title: mapName[index]['title']!, isBottomOffer: true, ); }, ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/services/home_services.dart
import 'dart:convert'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; import '../../../constants/error_handling.dart'; import '../../../constants/global_variables.dart'; import '../../../constants/utils.dart'; import '../../../models/product.dart'; class HomeServices { Future<List<Product>> fetchCategoryProducts( {required BuildContext context, required String category}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); List<Product> productList = []; try { http.Response res = await http .get(Uri.parse('$uri/api/products?category=$category'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { for (int i = 0; i < jsonDecode(res.body).length; i++) { productList.add( Product.fromJson( jsonEncode( jsonDecode(res.body)[i], ), ), ); } }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } return productList; } Future<Product> fetchDealOfTheDay({required BuildContext context}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); Product product = Product( name: '', description: '', quantity: 0, images: [], category: '', price: 0); try { http.Response res = await http.get(Uri.parse("$uri/api/deal-of-the-day"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { product = Product.fromJson(res.body); }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } return product; } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/screens/home_screen.dart
import 'package:amazon_clone_flutter/features/home/widgets/address_bar.dart'; import 'package:amazon_clone_flutter/features/home/widgets/deal_of_the_day.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../common/widgets/custom_app_bar.dart'; import '../../../constants/global_variables.dart'; import '../widgets/carousel_image.dart'; import '../widgets/multi_image_offer.dart'; import '../widgets/single_image_offer.dart'; import '../widgets/top_categories.dart'; class HomeScreen extends StatefulWidget { static const String routeName = '/home'; const HomeScreen({super.key}); @override State<HomeScreen> createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> { @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context).user; return Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar(), ), body: SingleChildScrollView( child: Column( children: [ user.address != '' ? const AddressBar() : const SizedBox(), const TopCategories(), const CarouselImage(), Container( decoration: const BoxDecoration( gradient: GlobalVariables.goldenGradient), child: const Padding( padding: EdgeInsets.symmetric(horizontal: 10), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ DealOfTheDay(), MultiImageOffer( mapName: GlobalVariables.multiImageOffer2, headtitle: 'Water bottles, lunch boxes, jars & more', subTitle: 'Minimum 60% off', productCategory: 'Home', ), SingleImageOffer( headTitle: 'Limited period offers on best-selling TVs | Starting ₹8,999', subTitle: 'Up to 18 months No Cost EMI', image: 'https://res.cloudinary.com/dthljz11q/image/upload/v1699881799/single_image_offers/ulrpitq6hf4rocgo0m8w.jpg', productCategory: 'Electronics', ), MultiImageOffer( mapName: GlobalVariables.multiImageOffer3, headtitle: 'Lowest prices on latest 4K smart TVs', subTitle: 'Save up to ₹40000 + Up to 3 years warranty', productCategory: 'Electronics', ), SingleImageOffer( headTitle: 'Top deals on headsets', subTitle: 'Up to 80% off', image: 'https://res.cloudinary.com/dthljz11q/image/upload/v1699881798/single_image_offers/x5gqgg5ynbjkslyvefpk.jpg', productCategory: 'Mobiles', ), MultiImageOffer( mapName: GlobalVariables.multiImageOffer1, headtitle: 'Deals on electronics and accessories', subTitle: 'Up to 75% off + Rs. 5000 back discount', productCategory: 'Grocrey', ), SizedBox.square( dimension: 10, ), SingleImageOffer( headTitle: 'Buy 2 Get 10% off, freebies & more offers', subTitle: 'See all offers', image: 'https://res.cloudinary.com/dthljz11q/image/upload/v1699881798/single_image_offers/u0ozqtcnhnl1eqoht85j.jpg', productCategory: 'Home', ), MultiImageOffer( mapName: GlobalVariables.multiImageOffer4, headtitle: 'Handpicked sports & fitness products', subTitle: 'Starting ₹49 + 20% cashback', productCategory: 'Home', ), SingleImageOffer( headTitle: 'Price crash | Amazon Brands & more', subTitle: 'Under ₹499 | T-shirts & shirts', image: 'https://res.cloudinary.com/dthljz11q/image/upload/v1699881800/single_image_offers/kwfypkjyfqjsipniefav.png', productCategory: 'Fashion', ), MultiImageOffer( mapName: GlobalVariables.multiImageOffer5, headtitle: 'Festival specials', subTitle: 'Minimum 40% off + Extra up to ₹120 cashback ', productCategory: 'Grocery', ), SingleImageOffer( headTitle: 'Amazon coupons | Smartphones & accessories', subTitle: 'Extra up to ₹2000 off with coupons', image: 'https://res.cloudinary.com/dthljz11q/image/upload/v1699881799/single_image_offers/rmtbk89pmenhd3mulcus.jpg', productCategory: 'Mobiles', ), SizedBox.square(dimension: 8) ], ), ), ), ], ), )); } }
0
mirrored_repositories/flutterzon_provider/lib/features/home
mirrored_repositories/flutterzon_provider/lib/features/home/screens/category_deals_screen.dart
import 'package:amazon_clone_flutter/features/home/services/home_services.dart'; import 'package:flutter/material.dart'; import '../../../common/widgets/custom_app_bar.dart'; import '../../../constants/utils.dart'; import '../../../models/product.dart'; import '../../../common/widgets/single_listing_product.dart'; class CategoryDealsScreen extends StatefulWidget { static const String routeName = '/category-deals'; final String category; const CategoryDealsScreen({super.key, required this.category}); @override State<CategoryDealsScreen> createState() => _CategoryDealsScreenState(); } class _CategoryDealsScreenState extends State<CategoryDealsScreen> { List<Product>? productList; final HomeServices homeServices = HomeServices(); @override void initState() { super.initState(); fetchCategoryProducts(); } fetchCategoryProducts() async { productList = await homeServices.fetchCategoryProducts( context: context, category: widget.category); productList!.shuffle(); setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar()), body: productList == null ? const Center(child: CircularProgressIndicator()) : Column( children: [ Container( width: double.infinity, padding: const EdgeInsets.all(8), margin: const EdgeInsets.symmetric(vertical: 4), decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade400, width: 0.4)), child: Text( 'Over ${productList!.length} Results in ${widget.category}', style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w300), ), ), Expanded( child: ListView.builder( itemCount: productList!.length, scrollDirection: Axis.vertical, itemBuilder: (context, index) { final product = productList![index]; final deliveryDate = getDeliveryDate(); return SingleListingProduct( product: product, deliveryDate: deliveryDate, ); }), ), ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features
mirrored_repositories/flutterzon_provider/lib/features/splash_screen/splash_screen.dart
import 'package:amazon_clone_flutter/common/widgets/bottom_bar.dart'; import 'package:amazon_clone_flutter/features/admin/screens/bottom_bar.dart'; import 'package:amazon_clone_flutter/features/auth/screens/auth_screen.dart'; import 'package:amazon_clone_flutter/features/auth/services/auth_service.dart'; import 'package:amazon_clone_flutter/models/user.dart'; import 'package:flutter/material.dart'; class SplashScreen extends StatelessWidget { const SplashScreen({ super.key, }); // @override @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( future: AuthService().getUserData(context), builder: (context, snapshot) { if (snapshot.hasData) { Future.delayed(Duration.zero, () { if (snapshot.data!.type == 'admin') { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => const AdminScreen())); } else if (snapshot.data!.type == 'user') { Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => const BottomBar())); } else { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => const AuthScreen())); } }); return Center( child: Image.asset( 'assets/images/amazon_in_alt.png', height: 52, )); } else { return Center( child: Image.asset( 'assets/images/amazon_in_alt.png', height: 52, )); } }, ), ); } } late final User user;
0
mirrored_repositories/flutterzon_provider/lib/features/address
mirrored_repositories/flutterzon_provider/lib/features/address/services/address_services.dart
import 'dart:convert'; import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/models/product.dart'; import 'package:amazon_clone_flutter/models/user.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; import '../../../constants/error_handling.dart'; import '../../../constants/global_variables.dart'; class AddressServices { void saveUserAddress({ required BuildContext context, required String address, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post( Uri.parse("$uri/api/save-user-address"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode( { 'address': address, }, ), ); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { User user = userProvider.user.copyWith( address: jsonDecode(res.body)['address'], wishList: jsonDecode(res.body)['wishList'], cart: jsonDecode(res.body)['cart'], keepShoppingFor: jsonDecode(res.body)['keepShoppingFor'], saveForLater: jsonDecode(res.body)['saveForLater'], ); userProvider.setUserFromModel(user); }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } void placeOrder({ required BuildContext context, required String address, required double totalSum, }) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post(Uri.parse("$uri/api/order"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode({ 'cart': userProvider.user.cart, 'address': address, 'totalPrice': totalSum, })); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { User user = userProvider.user.copyWith( cart: [], wishList: jsonDecode(res.body)['wishList'], keepShoppingFor: jsonDecode(res.body)['keepShoppingFor'], saveForLater: jsonDecode(res.body)['saveForLater']); userProvider.setUserFromModel(user); showSnackBar(context, 'Your order has been placed!'); Navigator.of(context).pop(); }, ); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } void placeOrderBuyNow( {required BuildContext context, required Product product, required String address}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); try { http.Response res = await http.post(Uri.parse("$uri/api/place-order-buy-now"), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }, body: jsonEncode( { 'id': product.id, 'totalPrice': product.price, 'address': address, }, )); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { showSnackBar(context, 'Your order has been placed! '); Navigator.of(context).pop(); }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } } }
0
mirrored_repositories/flutterzon_provider/lib/features/address
mirrored_repositories/flutterzon_provider/lib/features/address/screens/address_screen_buy_now.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/address/services/address_services.dart'; import 'package:amazon_clone_flutter/models/product.dart'; import 'package:flutter/material.dart'; import 'package:pay/pay.dart'; import 'package:provider/provider.dart'; import '../../../common/widgets/custom_textfield.dart'; import '../../../constants/global_variables.dart'; import '../../../providers/user_provider.dart'; class AddressScreenBuyNow extends StatefulWidget { static const String routeName = '/address-screen-buy-now'; final Product product; const AddressScreenBuyNow({super.key, required this.product}); @override State<AddressScreenBuyNow> createState() => _AddressScreenBuyNowState(); } class _AddressScreenBuyNowState extends State<AddressScreenBuyNow> { final TextEditingController flatBuildingController = TextEditingController(); final TextEditingController areaController = TextEditingController(); final TextEditingController pincodeController = TextEditingController(); final TextEditingController cityController = TextEditingController(); final _addressFormKey = GlobalKey<FormState>(); String addressToBeUsed = ''; List<PaymentItem> paymentItems = []; final Future<PaymentConfiguration> _googlePayConfigFuture = PaymentConfiguration.fromAsset('gpay.json'); final AddressServices addressServices = AddressServices(); @override void dispose() { super.dispose(); flatBuildingController.dispose(); areaController.dispose(); pincodeController.dispose(); cityController.dispose(); } @override void initState() { super.initState(); paymentItems.add(PaymentItem( amount: widget.product.price.toString(), label: 'Total Amount', status: PaymentItemStatus.final_price)); } void onPaymentResult(res) { if (Provider.of<UserProvider>(context, listen: false) .user .address .isEmpty) { addressServices.saveUserAddress( context: context, address: addressToBeUsed); } addressServices.placeOrderBuyNow( context: context, product: widget.product, address: addressToBeUsed); } void payPressed(String addressFromProvider) { addressToBeUsed = ''; bool isFromForm = flatBuildingController.text.isNotEmpty || areaController.text.isNotEmpty || pincodeController.text.isNotEmpty || cityController.text.isNotEmpty; if (isFromForm) { if (_addressFormKey.currentState!.validate()) { addressToBeUsed = '${flatBuildingController.text}, ${areaController.text}, ${cityController.text}, ${pincodeController.text}'; } else { throw Exception('Please enter all the values'); } } else if (addressToBeUsed.isEmpty) { addressToBeUsed = addressFromProvider; } else { showSnackBar(context, 'ERROR'); } } @override Widget build(BuildContext context) { var address = context.watch<UserProvider>().user.address; return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), child: AppBar( flexibleSpace: Container( decoration: const BoxDecoration(gradient: GlobalVariables.appBarGradient), ), ), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ const Text( 'SubTotal ', style: TextStyle( fontSize: 20, fontWeight: FontWeight.normal, color: Colors.black87), ), const Text( '₹', style: TextStyle( fontSize: 18, color: Colors.black87, fontWeight: FontWeight.w400), ), Text( formatPriceWithDecimal(widget.product.price), style: const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), ), ], ), const SizedBox(height: 10), if (address.isNotEmpty) Column( children: [ Container( width: double.infinity, decoration: BoxDecoration( border: Border.all(color: Colors.black12)), child: Padding( padding: const EdgeInsets.all(8.0), child: Text( address, style: const TextStyle(fontSize: 18), ), ), ), const SizedBox( height: 20, ), const Text( 'OR', style: TextStyle(fontSize: 18), ), ], ), const SizedBox( height: 20, ), Form( key: _addressFormKey, child: Column( children: [ CustomTextfield( controller: flatBuildingController, hintText: 'Flat, house no, building', ), CustomTextfield( controller: areaController, hintText: 'Area, street', ), CustomTextfield( controller: pincodeController, hintText: 'Pincode', ), CustomTextfield( controller: cityController, hintText: 'Town/city', ), const SizedBox( height: 5, ) ], ), ), FutureBuilder<PaymentConfiguration>( future: _googlePayConfigFuture, builder: (context, snapshot) => snapshot.hasData ? GooglePayButton( onPressed: () => payPressed(address), width: double.infinity, height: 50, paymentConfiguration: snapshot.data!, paymentItems: paymentItems, type: GooglePayButtonType.buy, margin: const EdgeInsets.only(top: 15.0), onPaymentResult: onPaymentResult, loadingIndicator: const Center( child: CircularProgressIndicator(), ), ) : const SizedBox.shrink()), ], ), ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/address
mirrored_repositories/flutterzon_provider/lib/features/address/screens/address_screen.dart
import 'package:amazon_clone_flutter/constants/utils.dart'; import 'package:amazon_clone_flutter/features/address/services/address_services.dart'; import 'package:flutter/material.dart'; import 'package:pay/pay.dart'; import 'package:provider/provider.dart'; import '../../../common/widgets/custom_textfield.dart'; import '../../../constants/global_variables.dart'; import '../../../providers/user_provider.dart'; class AddressScreen extends StatefulWidget { static const String routeName = '/address'; final String totalAmount; const AddressScreen({super.key, required this.totalAmount}); @override State<AddressScreen> createState() => _AddressScreenState(); } class _AddressScreenState extends State<AddressScreen> { final TextEditingController flatBuildingController = TextEditingController(); final TextEditingController areaController = TextEditingController(); final TextEditingController pincodeController = TextEditingController(); final TextEditingController cityController = TextEditingController(); final _addressFormKey = GlobalKey<FormState>(); String addressToBeUsed = ''; List<PaymentItem> paymentItems = []; final Future<PaymentConfiguration> _googlePayConfigFuture = PaymentConfiguration.fromAsset('gpay.json'); final AddressServices addressServices = AddressServices(); @override void dispose() { super.dispose(); flatBuildingController.dispose(); areaController.dispose(); pincodeController.dispose(); cityController.dispose(); } @override void initState() { super.initState(); paymentItems.add(PaymentItem( amount: widget.totalAmount, label: 'Total Amount', status: PaymentItemStatus.final_price)); } void onPaymentResult(res) { if (Provider.of<UserProvider>(context, listen: false) .user .address .isEmpty) { addressServices.saveUserAddress( context: context, address: addressToBeUsed); } addressServices.placeOrder( context: context, address: addressToBeUsed, totalSum: double.parse(widget.totalAmount)); } void payPressed(String addressFromProvider) { addressToBeUsed = ''; bool isFromForm = flatBuildingController.text.isNotEmpty || areaController.text.isNotEmpty || pincodeController.text.isNotEmpty || cityController.text.isNotEmpty; if (isFromForm) { if (_addressFormKey.currentState!.validate()) { addressToBeUsed = '${flatBuildingController.text}, ${areaController.text}, ${cityController.text}, ${pincodeController.text}'; } else { throw Exception('Please enter all the values'); } } else if (addressToBeUsed.isEmpty) { addressToBeUsed = addressFromProvider; } else { showSnackBar(context, 'ERROR'); } } @override Widget build(BuildContext context) { var address = context.watch<UserProvider>().user.address; return Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), child: AppBar( flexibleSpace: Container( decoration: const BoxDecoration(gradient: GlobalVariables.appBarGradient), ), ), ), body: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ const Text( 'SubTotal ', style: TextStyle( fontSize: 20, fontWeight: FontWeight.normal, color: Colors.black87), ), const Text( '₹', style: TextStyle( fontSize: 18, color: Colors.black87, fontWeight: FontWeight.w400), ), Text( formatPriceWithDecimal(double.parse(widget.totalAmount)), style: const TextStyle( fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), ), ], ), const SizedBox(height: 10), if (address.isNotEmpty) Column( children: [ Container( width: double.infinity, decoration: BoxDecoration( border: Border.all(color: Colors.black12)), child: Padding( padding: const EdgeInsets.all(8.0), child: Text( address, style: const TextStyle(fontSize: 18), ), ), ), const SizedBox( height: 20, ), const Text( 'OR', style: TextStyle(fontSize: 18), ), ], ), const SizedBox( height: 20, ), Form( key: _addressFormKey, child: Column( children: [ CustomTextfield( controller: flatBuildingController, hintText: 'Flat, house no, building', ), CustomTextfield( controller: areaController, hintText: 'Area, street', ), CustomTextfield( controller: pincodeController, hintText: 'Pincode', ), CustomTextfield( controller: cityController, hintText: 'Town/city', ), const SizedBox( height: 5, ) ], ), ), FutureBuilder<PaymentConfiguration>( future: _googlePayConfigFuture, builder: (context, snapshot) => snapshot.hasData ? GooglePayButton( onPressed: () => payPressed(address), width: double.infinity, height: 50, paymentConfiguration: snapshot.data!, paymentItems: paymentItems, type: GooglePayButtonType.buy, margin: const EdgeInsets.only(top: 15.0), onPaymentResult: onPaymentResult, loadingIndicator: const Center( child: CircularProgressIndicator(), ), ) : const SizedBox.shrink()), ], ), ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/search
mirrored_repositories/flutterzon_provider/lib/features/search/widgets/searched_product.dart
import 'package:amazon_clone_flutter/common/widgets/stars.dart'; import 'package:amazon_clone_flutter/models/product.dart'; import 'package:flutter/material.dart'; class SearchedProduct extends StatelessWidget { const SearchedProduct({super.key, required this.product}); final Product product; @override Widget build(BuildContext context) { double totalRating = 0; for (int i = 0; i < product.rating!.length; i++) { totalRating += product.rating![i].rating; } double averageRating = 0; if (totalRating != 0) { averageRating = totalRating / product.rating!.length; } return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( margin: const EdgeInsets.symmetric(horizontal: 10), child: Row(children: [ Image.network( product.images[0], fit: BoxFit.contain, height: 135, width: 135, ), Column( children: [ Container( width: 235, padding: const EdgeInsets.symmetric(horizontal: 10), child: Text( product.name, maxLines: 2, style: const TextStyle( fontSize: 16, overflow: TextOverflow.ellipsis), ), ), Container( width: 235, padding: const EdgeInsets.symmetric(horizontal: 10), child: Stars(rating: averageRating), ), Container( width: 235, padding: const EdgeInsets.symmetric(horizontal: 10), child: const Text('Eligible for FREE shipping'), ), Container( width: 235, padding: const EdgeInsets.only(top: 5, left: 10), child: Text( '\$${product.price}', style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold), maxLines: 2, ), ), Container( width: 235, padding: const EdgeInsets.only(top: 5, left: 10), child: const Text( 'In Stock', style: TextStyle( color: Colors.teal, ), maxLines: 2, ), ), ], ) ]), ) ], ); } }
0
mirrored_repositories/flutterzon_provider/lib/features/search
mirrored_repositories/flutterzon_provider/lib/features/search/services/search_services.dart
import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart' as http; import '../../../constants/error_handling.dart'; import '../../../constants/global_variables.dart'; import '../../../constants/utils.dart'; import '../../../models/product.dart'; import '../../../providers/user_provider.dart'; class SearchServices { Future<List<Product>> fetchSearchedProducts( {required BuildContext context, required String searchQuery}) async { final userProvider = Provider.of<UserProvider>(context, listen: false); List<Product> productList = []; try { http.Response res = await http .get(Uri.parse('$uri/api/products/search/$searchQuery'), headers: { 'Content-Type': 'application/json; charset=UTF-8', 'x-auth-token': userProvider.user.token, }); if (context.mounted) { httpErrorHandle( response: res, context: context, onSuccess: () { for (int i = 0; i < jsonDecode(res.body).length; i++) { productList.add( Product.fromJson( jsonEncode( jsonDecode(res.body)[i], ), ), ); } }); } } catch (e) { if (context.mounted) { showSnackBar(context, e.toString()); } } return productList; } }
0
mirrored_repositories/flutterzon_provider/lib/features/search
mirrored_repositories/flutterzon_provider/lib/features/search/screens/search_screen.dart
import 'package:amazon_clone_flutter/features/home/widgets/address_bar.dart'; import 'package:amazon_clone_flutter/common/widgets/single_listing_product.dart'; import 'package:amazon_clone_flutter/features/product_details/screens/product_details_screen.dart'; import 'package:amazon_clone_flutter/features/search/services/search_services.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../../common/widgets/custom_app_bar.dart'; import '../../../constants/utils.dart'; import '../../../models/product.dart'; class SearchScreen extends StatefulWidget { static const routeName = '/search-screen'; const SearchScreen({super.key, required this.searchQuery}); final String searchQuery; @override State<SearchScreen> createState() => _SearchScreenState(); } class _SearchScreenState extends State<SearchScreen> { List<Product>? products; final SearchServices searchServices = SearchServices(); @override void initState() { super.initState(); fetchSearchProducts(); } fetchSearchProducts() async { products = await searchServices.fetchSearchedProducts( context: context, searchQuery: widget.searchQuery); setState(() {}); } @override Widget build(BuildContext context) { final user = Provider.of<UserProvider>(context).user; return products == null ? const Scaffold(body: Center(child: CircularProgressIndicator())) : Scaffold( appBar: const PreferredSize( preferredSize: Size.fromHeight(60), child: CustomAppBar(), ), body: products == null ? const Center(child: CircularProgressIndicator()) : Column( children: [ user.address != '' ? const AddressBar() : const SizedBox(), const SizedBox( height: 10, ), Expanded( child: ListView.builder( itemCount: products!.length, itemBuilder: ((context, index) { final product = products![index]; return GestureDetector( onTap: () { Navigator.pushNamed( context, ProductDetailsScreen.routeName, arguments: product); }, child: SingleListingProduct( product: product, deliveryDate: getDeliveryDate(), )); })), ) ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/models/rating.dart
import 'dart:convert'; class Rating { final String userId; final double rating; Rating({required this.userId, required this.rating}); Map<String, dynamic> toMap() { return { 'userId': userId, 'rating': rating, }; } factory Rating.fromMap(Map<String, dynamic> map) { return Rating( userId: map['userId'] ?? '', rating: map['rating']?.toDouble() ?? 0.0, ); } String toJson() => json.encode(toMap()); factory Rating.fromJson(String source) => Rating.fromMap(json.decode(source)); }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/models/order.dart
import 'dart:convert'; import 'package:amazon_clone_flutter/models/product.dart'; class Order { final String id; final List<Product> products; final List<int> quantity; final String address; final String userId; final int orderedAt; final int status; final double totalPrice; Order({ required this.id, required this.products, required this.quantity, required this.address, required this.userId, required this.orderedAt, required this.status, required this.totalPrice, }); Map<String, dynamic> toMap() { return { 'id': id, 'products': products.map((x) => x.toMap()).toList(), 'quantity': quantity, 'address': address, 'userId': userId, 'orderedAt': orderedAt, 'status': status, 'totalPrice': totalPrice, }; } factory Order.fromMap(Map<String, dynamic> map) { return Order( id: map['_id'] ?? '', products: List<Product>.from( map['products']?.map((x) => Product.fromMap(x['product']))), quantity: List<int>.from( map['products']?.map( (x) => x['quantity'], ), ), address: map['address'] ?? '', userId: map['userId'] ?? '', orderedAt: map['orderedAt']?.toInt() ?? 0, status: map['status']?.toInt() ?? 0, totalPrice: map['totalPrice']?.toDouble() ?? 0.0, ); } String toJson() => json.encode(toMap()); factory Order.fromJson(String source) => Order.fromMap(json.decode(source)); }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/models/product.dart
import 'dart:convert'; import 'package:amazon_clone_flutter/models/rating.dart'; class Product { final String name; final String description; final int quantity; final List<String> images; final String category; final double price; final String? id; final List<Rating>? rating; Product( {required this.name, required this.description, required this.quantity, required this.images, required this.category, required this.price, this.id, this.rating}); Map<String, dynamic> toMap() { return { 'name': name, 'description': description, 'quantity': quantity, 'images': images, 'category': category, 'price': price, 'id': id, 'rating': rating, }; } factory Product.fromMap(Map<String, dynamic> map) { return Product( name: map['name'] ?? '', description: map['description'] ?? '', quantity: map['quantity']?.toInt() ?? 0, images: List<String>.from(map['images']), category: map['category'] ?? '', price: map['price']?.toDouble() ?? 0.0, id: map['_id'], rating: map['ratings'] != null ? List<Rating>.from( map['ratings']?.map( (x) => Rating.fromMap(x), ), ) : null); } String toJson() => json.encode(toMap()); factory Product.fromJson(String source) => Product.fromMap(json.decode(source)); }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/models/user.dart
import 'dart:convert'; class User { final String id; final String name; final String email; final String password; final String address; final String type; final String token; final List<dynamic> cart; final List<dynamic> saveForLater; final List<dynamic> keepShoppingFor; final List<dynamic> wishList; User({ required this.id, required this.name, required this.email, required this.password, required this.address, required this.type, required this.token, required this.cart, required this.saveForLater, required this.keepShoppingFor, required this.wishList, }); Map<String, dynamic> toMap() { return { 'id': id, 'name': name, 'email': email, 'password': password, 'address': address, 'type': type, 'token': token, 'cart': cart, 'saveForLater': saveForLater, 'keepShoppingFor': keepShoppingFor, 'wishList': wishList, }; } factory User.fromMap(Map<String, dynamic> map) { return User( id: map['_id'] ?? '', name: map['name'] ?? '', email: map['email'] ?? '', password: map['password'] ?? '', address: map['address'] ?? '', type: map['type'] ?? '', token: map['token'] ?? '', cart: List<Map<String, dynamic>>.from( map['cart']?.map( (x) => Map<String, dynamic>.from(x), ), ), saveForLater: List<Map<String, dynamic>>.from( map['saveForLater']?.map( (x) => Map<String, dynamic>.from(x), ), ), keepShoppingFor: List<Map<String, dynamic>>.from( map['keepShoppingFor']?.map( (x) => Map<String, dynamic>.from(x), ), ), wishList: List<Map<String, dynamic>>.from( map['wishList']?.map( (x) => Map<String, dynamic>.from(x), ), ), ); } String toJson() => json.encode(toMap()); factory User.fromJson(String source) => User.fromMap(json.decode(source)); User copyWith({ String? id, String? name, String? email, String? password, String? address, String? type, String? token, List<dynamic>? cart, List<dynamic>? saveForLater, List<dynamic>? keepShoppingFor, List<dynamic>? wishList, }) { return User( id: id ?? this.id, name: name ?? this.name, email: email ?? this.email, password: password ?? this.password, address: address ?? this.address, type: type ?? this.type, token: token ?? this.token, cart: cart ?? this.cart, saveForLater: saveForLater ?? this.saveForLater, keepShoppingFor: keepShoppingFor ?? this.keepShoppingFor, wishList: wishList ?? this.wishList, ); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/custom_elevated_button.dart
import 'package:flutter/material.dart'; import '../../constants/global_variables.dart'; class CustomElevatedButton extends StatelessWidget { const CustomElevatedButton( {super.key, required this.buttonText, required this.onPressed, this.isRectangle = false, this.color = GlobalVariables.yellowColor}); final String buttonText; final Function()? onPressed; final Color color; final bool isRectangle; @override Widget build(BuildContext context) { return ElevatedButton( onPressed: onPressed, style: ButtonStyle( backgroundColor: MaterialStatePropertyAll(color), elevation: const MaterialStatePropertyAll(0), shape: MaterialStatePropertyAll(RoundedRectangleBorder( borderRadius: isRectangle ? const BorderRadius.all(Radius.circular(8)) : const BorderRadius.all(Radius.circular(25)))), fixedSize: MaterialStatePropertyAll( Size(MediaQuery.sizeOf(context).width, 45))), child: Text( buttonText, style: const TextStyle( color: Colors.black87, fontWeight: FontWeight.w400, fontSize: 16), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/bottom_bar.dart
import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:amazon_clone_flutter/features/account/screens/account_screen.dart'; import 'package:amazon_clone_flutter/features/cart/screens/cart_screen.dart'; import 'package:amazon_clone_flutter/features/home/screens/home_screen.dart'; import 'package:amazon_clone_flutter/features/menu/screens/menu_screen.dart'; import 'package:amazon_clone_flutter/providers/user_provider.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../features/more/screens/more_screen.dart'; import '../../providers/screen_number_provider.dart'; class BottomBar extends StatefulWidget { static const String routeName = '/bottomBar'; const BottomBar({super.key}); @override State<BottomBar> createState() => _BottomBarState(); } class _BottomBarState extends State<BottomBar> { int _page = 0; double bottomBarWidth = 42; double bottomBarBorderWidth = 5; bool isItOpen = false; List<Widget> pages = [ const HomeScreen(), const AccountScreen(), const MoreScreen(), const CartScreen(), const MenuScreen(), ]; @override Widget build(BuildContext context) { final userCartLength = context.watch<UserProvider>().user.cart.length; final screenNumberProvider = Provider.of<ScreenNumberProvider>(context, listen: false); final isOpen = Provider.of<ScreenNumberProvider>(context, listen: false); return Scaffold( body: pages[_page], bottomNavigationBar: SafeArea( child: Theme( data: ThemeData( splashColor: Colors.transparent, highlightColor: Colors.transparent), child: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: _page, showSelectedLabels: _page == 2 && isOpen.isOpen == true ? false : true, showUnselectedLabels: true, selectedFontSize: 13, unselectedFontSize: 13, selectedLabelStyle: TextStyle( color: _page != 2 ? GlobalVariables.selectedNavBarColor : GlobalVariables.unselectedNavBarColor, fontSize: 13), unselectedLabelStyle: const TextStyle( color: GlobalVariables.unselectedNavBarColor, fontSize: 13), selectedItemColor: _page != 2 ? GlobalVariables.selectedNavBarColor : GlobalVariables.unselectedNavBarColor, unselectedItemColor: GlobalVariables.unselectedNavBarColor, backgroundColor: GlobalVariables.backgroundColor, enableFeedback: false, iconSize: 28, elevation: 0, onTap: (page) { if (page != 2) { screenNumberProvider.setScreenNumber(page); } if (page == 2 && isOpen.isOpen == false) { isItOpen = true; isOpen.setIsOpen(isItOpen); } else { isItOpen = false; isOpen.setIsOpen(isItOpen); } if (page == 2 && isOpen.isOpen == false && _page == 2) { setState(() { _page = isOpen.screenNumber; }); } else { setState(() { _page = page; }); } }, items: [ bottomNavBarItem( icon: bottomBarImage(iconName: 'home', page: 0), page: 0, label: 'Home', ), bottomNavBarItem( icon: bottomBarImage(iconName: 'you', page: 1), page: 1, label: 'You', ), bottomNavBarItem( icon: bottomBarImage(iconName: 'more', page: 2), page: 2, label: 'More', ), bottomNavBarItem( icon: Stack( children: [ bottomBarImage( iconName: 'cart', page: 3, width: 25, height: 25), Positioned( top: 0, left: 10, child: Text( userCartLength.toString(), style: TextStyle( fontWeight: FontWeight.bold, color: _page == 3 ? GlobalVariables.selectedNavBarColor : GlobalVariables.unselectedNavBarColor), ), ), ], ), page: 3, label: 'Cart', ), bottomNavBarItem( icon: bottomBarImage(iconName: 'menu', page: 4), page: 4, label: 'Menu', ), ], ), ), ), ); } BottomNavigationBarItem bottomNavBarItem({ required Widget icon, required int page, required String label, }) { return BottomNavigationBarItem( icon: Column( children: [ Container( width: bottomBarWidth, height: 5.5, decoration: BoxDecoration( color: _page == page && _page != 2 ? GlobalVariables.selectedNavBarColor : Colors.white, borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(5), bottomRight: Radius.circular(5), ), ), ), const SizedBox( height: 6, ), icon, const SizedBox( height: 6, ), ], ), label: label); } Image bottomBarImage( {required String iconName, required int page, double height = 20, double width = 20}) { final screenNumberProvider = Provider.of<ScreenNumberProvider>(context, listen: false); return Image.asset('assets/images/bottom_nav_bar/$iconName.png', height: height, width: width, color: _page == 2 && screenNumberProvider.isOpen == true && _page == page ? GlobalVariables.selectedNavBarColor : _page != 2 && screenNumberProvider.isOpen == false && _page == page ? GlobalVariables.selectedNavBarColor : GlobalVariables.unselectedNavBarColor); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/you_might_also_like_single.dart
import 'package:amazon_clone_flutter/common/widgets/stars.dart'; import 'package:flutter/material.dart'; import '../../constants/global_variables.dart'; import '../../constants/utils.dart'; import '../../models/product.dart'; class YouMightAlsoLikeSingle extends StatefulWidget { const YouMightAlsoLikeSingle({ super.key, required this.product, }); final Product product; @override State<YouMightAlsoLikeSingle> createState() => _YouMightAlsoLikeSingleState(); } String? price; class _YouMightAlsoLikeSingleState extends State<YouMightAlsoLikeSingle> { @override void initState() { super.initState(); price = formatPrice(widget.product.price); } @override Widget build(BuildContext context) { double totalRating = 0; for (int i = 0; i < widget.product.rating!.length; i++) { totalRating += widget.product.rating![i].rating; } double averageRating = 0; if (totalRating != 0) { averageRating = totalRating / widget.product.rating!.length; } return Container( margin: const EdgeInsets.symmetric(horizontal: 6), padding: const EdgeInsets.symmetric(horizontal: 4), width: 130, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Center( child: Image.network( widget.product.images[0], height: 130, ), ), Text( widget.product.name, maxLines: 2, style: TextStyle( fontSize: 16, color: GlobalVariables.selectedNavBarColor, overflow: TextOverflow.ellipsis), ), Stars( rating: averageRating, size: 18, ), Text( '${widget.product.rating!.length.toString()} reviews', style: const TextStyle( color: Colors.black54, fontSize: 14, fontWeight: FontWeight.normal, ), ), Text( '₹$price.00', maxLines: 2, style: const TextStyle( fontSize: 16, color: Color(0xffB12704), fontWeight: FontWeight.w500, overflow: TextOverflow.ellipsis), ), ], ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/custom_textfield.dart
import 'package:flutter/material.dart'; class CustomTextfield extends StatelessWidget { final TextEditingController controller; final String hintText; final int maxLines; const CustomTextfield( {super.key, required this.controller, required this.hintText, this.maxLines = 1}); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.all(5), child: TextFormField( controller: controller, maxLines: maxLines, decoration: InputDecoration( // constraints: const BoxConstraints(minHeight: 70, maxHeight: 70), hintText: hintText, hintStyle: const TextStyle(fontWeight: FontWeight.w400), border: const OutlineInputBorder( borderSide: BorderSide(color: Colors.black38), ), enabledBorder: const OutlineInputBorder( borderSide: BorderSide(color: Colors.black38), ), ), validator: (val) { if (val == null || val.isEmpty) { return 'This field cannot be empty'; } return null; }, ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/single_listing_product.dart
import 'package:amazon_clone_flutter/features/product_details/services/product_details_services.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import '../../constants/utils.dart'; import '../../features/product_details/screens/product_details_screen.dart'; import 'stars.dart'; import '../../constants/global_variables.dart'; import '../../models/product.dart'; class SingleListingProduct extends StatefulWidget { const SingleListingProduct({ super.key, required this.product, required this.deliveryDate, }); final Product? product; final String? deliveryDate; @override State<SingleListingProduct> createState() => _SingleListingProductState(); } class _SingleListingProductState extends State<SingleListingProduct> { final ProductDetailsServices productDetailsServices = ProductDetailsServices(); double averageRating = 0; String? price; getAverageRating() async { averageRating = await productDetailsServices.getAverageRating( context: context, product: widget.product!); setState(() {}); } @override void initState() { super.initState(); price = formatPrice(widget.product!.price); getAverageRating(); } @override Widget build(BuildContext context) { const productTextStyle = TextStyle( fontSize: 12, color: Colors.black54, fontWeight: FontWeight.normal); return GestureDetector( onTap: () { Navigator.pushNamed(context, ProductDetailsScreen.routeName, arguments: { 'product': widget.product, 'deliveryDate': widget.deliveryDate, }); }, child: Container( height: 180, margin: const EdgeInsets.symmetric(vertical: 6), decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade300, width: 0.5), borderRadius: BorderRadius.circular(5)), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: 180, width: 160, decoration: const BoxDecoration(color: Color(0xffF7F7F7)), child: Padding( padding: const EdgeInsets.all(15), child: CachedNetworkImage( imageUrl: widget.product!.images[0], fit: BoxFit.contain, ), ), ), Expanded( child: Padding( padding: const EdgeInsets.only( left: 10, right: 4, top: 4, bottom: 4), child: Flex( direction: Axis.vertical, crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( widget.product!.name, maxLines: 2, style: const TextStyle( fontSize: 16, overflow: TextOverflow.ellipsis), ), Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( averageRating.toStringAsFixed(1), style: TextStyle( fontSize: 14, fontWeight: FontWeight.w500, color: GlobalVariables.selectedNavBarColor), ), Stars( rating: averageRating, size: 20, ), Text('(${widget.product!.rating!.length})', style: productTextStyle.copyWith(fontSize: 14)), ], ), Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ const Text( '₹', style: TextStyle( fontSize: 18, color: Colors.black, fontWeight: FontWeight.w400), ), Text( price!, style: const TextStyle( fontSize: 24, fontWeight: FontWeight.w400), ), ], ), // const SizedBox(height: 4), RichText( text: TextSpan( text: 'Get it by ', style: productTextStyle, children: [ TextSpan( text: widget.deliveryDate, style: const TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: Color(0xff56595A)), ) ]), ), // const SizedBox(height: 4), const Text( 'FREE Delivery by Amazon', style: productTextStyle, ), // const SizedBox(height: 4), const Text( '7 days Replacement', style: productTextStyle, ), ], ), ), ) ], ), ), ); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/custom_app_bar.dart
import 'package:flutter/material.dart'; import '../../constants/global_variables.dart'; import '../../features/home/widgets/search_text_form_field.dart'; import '../../features/search/screens/search_screen.dart'; class CustomAppBar extends StatelessWidget { const CustomAppBar({ super.key, }); @override Widget build(BuildContext context) { return AppBar( flexibleSpace: Container( decoration: const BoxDecoration(gradient: GlobalVariables.appBarGradient), ), title: SearchTextFormField(onTapSearchField: (String query) { Navigator.pushNamed(context, SearchScreen.routeName, arguments: query); }), ); } }
0
mirrored_repositories/flutterzon_provider/lib/common
mirrored_repositories/flutterzon_provider/lib/common/widgets/stars.dart
import 'package:amazon_clone_flutter/constants/global_variables.dart'; import 'package:flutter/material.dart'; import 'package:flutter_rating_bar/flutter_rating_bar.dart'; class Stars extends StatelessWidget { final double rating; final double size; const Stars({super.key, required this.rating, this.size = 15}); @override Widget build(BuildContext context) { return RatingBarIndicator( direction: Axis.horizontal, itemCount: 5, rating: rating, itemSize: size, itemBuilder: (context, _) => const Icon( Icons.star, color: GlobalVariables.secondaryColor, )); } }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/providers/user_provider.dart
import 'package:amazon_clone_flutter/models/user.dart'; import 'package:flutter/material.dart'; class UserProvider extends ChangeNotifier { User _user = User( id: '', name: '', email: '', password: '', address: '', type: '', token: '', cart: [], saveForLater: [], keepShoppingFor: [], wishList: [], ); User get user => _user; void setUser(String user) { _user = User.fromJson(user); notifyListeners(); } void setUserFromModel(User user) { _user = user; notifyListeners(); } }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/providers/cart_offers_provider.dart
import 'package:flutter/material.dart'; class CartOfferProvider extends ChangeNotifier { String _category1 = ''; String get category1 => _category1; void setCategory1(String category) { _category1 = category; notifyListeners(); } }
0
mirrored_repositories/flutterzon_provider/lib
mirrored_repositories/flutterzon_provider/lib/providers/screen_number_provider.dart
import 'package:flutter/material.dart'; class ScreenNumberProvider extends ChangeNotifier { int _screenNumber = 0; static bool _isOpen = false; int get screenNumber => _screenNumber; bool get isOpen => _isOpen; void setScreenNumber(int number) { _screenNumber = number; notifyListeners(); } void setIsOpen(bool isOpen) { _isOpen = isOpen; notifyListeners(); } }
0
mirrored_repositories/flutterzon_provider
mirrored_repositories/flutterzon_provider/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:amazon_clone_flutter/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/pdf_generate
mirrored_repositories/pdf_generate/lib/file_handle_api.dart
import 'dart:io'; import 'package:pdf/widgets.dart' as pw; import 'package:path_provider/path_provider.dart'; import 'package:open_file/open_file.dart'; class FileHandleApi { // save pdf file function static Future<File> saveDocument({ required String name, required pw.Document pdf, }) async { final bytes = await pdf.save(); // final dir = await getApplicationDocumentsDirectory(); final dir = await getExternalStorageDirectory(); final file = File('${dir?.path}/$name'); await file.writeAsBytes(bytes); return file; } // open pdf file function static Future openFile(File file) async { final url = file.path; await OpenFile.open(url); } }
0
mirrored_repositories/pdf_generate
mirrored_repositories/pdf_generate/lib/pdf_invoice_api.dart
import 'dart:io'; import 'package:flutter/services.dart'; import 'package:pdf/pdf.dart'; import 'package:pdf/widgets.dart' as pw; import 'file_handle_api.dart'; class PdfInvoiceApi { static Future<File> generate() async { final pdf = pw.Document(); final iconImage = (await rootBundle.load('assets/icon.png')).buffer.asUint8List(); final tableHeaders = [ 'Description', 'Quantity', 'Unit Price', 'VAT', 'Total', ]; final tableData = [ [ 'Coffee', '7', '\$ 5', '1 %', '\$ 35', ], [ 'Blue Berries', '5', '\$ 10', '2 %', '\$ 50', ], [ 'Water', '1', '\$ 3', '1.5 %', '\$ 3', ], [ 'Apple', '6', '\$ 8', '2 %', '\$ 48', ], [ 'Lunch', '3', '\$ 90', '12 %', '\$ 270', ], [ 'Drinks', '2', '\$ 15', '0.5 %', '\$ 30', ], [ 'Lemon', '4', '\$ 7', '0.5 %', '\$ 28', ], ]; pdf.addPage( pw.MultiPage( build: (context) { return [ pw.Row( children: [ pw.Image( pw.MemoryImage(iconImage), height: 72, width: 72, ), pw.SizedBox(width: 1 * PdfPageFormat.mm), pw.Column( mainAxisSize: pw.MainAxisSize.min, crossAxisAlignment: pw.CrossAxisAlignment.start, children: [ pw.Text( 'INVOICE', style: pw.TextStyle( fontSize: 17.0, fontWeight: pw.FontWeight.bold, ), ), pw.Text( 'Flutter Approach', style: const pw.TextStyle( fontSize: 15.0, color: PdfColors.grey700, ), ), ], ), pw.Spacer(), pw.Column( mainAxisSize: pw.MainAxisSize.min, crossAxisAlignment: pw.CrossAxisAlignment.start, children: [ pw.Text( 'Abdulrahman', style: pw.TextStyle( fontSize: 15.5, fontWeight: pw.FontWeight.bold, ), ), pw.Text( '[email protected]', ), pw.Text( DateTime.now().toString(), ), ], ), ], ), pw.SizedBox(height: 1 * PdfPageFormat.mm), pw.Divider(), pw.SizedBox(height: 1 * PdfPageFormat.mm), pw.Text( 'Dear John,\nLorem ipsum dolor sit amet consectetur adipisicing elit. Maxime mollitia, molestiae quas vel sint commodi repudiandae consequuntur voluptatum laborum numquam blanditiis harum quisquam eius sed odit fugiat iusto fuga praesentium optio, eaque rerum! Provident similique accusantium nemo autem. Veritatis obcaecati tenetur iure eius earum ut molestias architecto voluptate aliquam nihil, eveniet aliquid culpa officia aut! Impedit sit sunt quaerat, odit, tenetur error', textAlign: pw.TextAlign.justify, ), pw.SizedBox(height: 5 * PdfPageFormat.mm), /// /// PDF Table Create /// pw.Table.fromTextArray( headers: tableHeaders, data: tableData, border: null, headerStyle: pw.TextStyle(fontWeight: pw.FontWeight.bold), headerDecoration: const pw.BoxDecoration(color: PdfColors.grey300), cellHeight: 30.0, cellAlignments: { 0: pw.Alignment.centerLeft, 1: pw.Alignment.centerRight, 2: pw.Alignment.centerRight, 3: pw.Alignment.centerRight, 4: pw.Alignment.centerRight, }, ), pw.Divider(), pw.Container( alignment: pw.Alignment.centerRight, child: pw.Row( children: [ pw.Spacer(flex: 6), pw.Expanded( flex: 4, child: pw.Column( crossAxisAlignment: pw.CrossAxisAlignment.start, children: [ pw.Row( children: [ pw.Expanded( child: pw.Text( 'Net total', style: pw.TextStyle( fontWeight: pw.FontWeight.bold, ), ), ), pw.Text( '\$ 464', style: pw.TextStyle( fontWeight: pw.FontWeight.bold, ), ), ], ), pw.Row( children: [ pw.Expanded( child: pw.Text( 'Vat 19.5 %', style: pw.TextStyle( fontWeight: pw.FontWeight.bold, ), ), ), pw.Text( '\$ 90.48', style: pw.TextStyle( fontWeight: pw.FontWeight.bold, ), ), ], ), pw.Divider(), pw.Row( children: [ pw.Expanded( child: pw.Text( 'Total amount due', style: pw.TextStyle( fontSize: 14.0, fontWeight: pw.FontWeight.bold, ), ), ), pw.Text( '\$ 554.48', style: pw.TextStyle( fontWeight: pw.FontWeight.bold, ), ), ], ), pw.SizedBox(height: 2 * PdfPageFormat.mm), pw.Container(height: 1, color: PdfColors.grey400), pw.SizedBox(height: 0.5 * PdfPageFormat.mm), pw.Container(height: 1, color: PdfColors.grey400), ], ), ), ], ), ), ]; }, footer: (context) { return pw.Column( mainAxisSize: pw.MainAxisSize.min, children: [ pw.Divider(), pw.SizedBox(height: 2 * PdfPageFormat.mm), pw.Text( 'Flutter Approach', style: pw.TextStyle(fontWeight: pw.FontWeight.bold), ), pw.SizedBox(height: 1 * PdfPageFormat.mm), pw.Row( mainAxisAlignment: pw.MainAxisAlignment.center, children: [ pw.Text( 'Address: ', style: pw.TextStyle(fontWeight: pw.FontWeight.bold), ), pw.Text( 'Egypt, Cairo - Nasr City - 8th Area', ), ], ), pw.SizedBox(height: 1 * PdfPageFormat.mm), pw.Row( mainAxisAlignment: pw.MainAxisAlignment.center, children: [ pw.Text( 'Email: ', style: pw.TextStyle(fontWeight: pw.FontWeight.bold), ), pw.Text( '[email protected]', ), ], ), ], ); }, ), ); return FileHandleApi.saveDocument(name: 'my_invoice.pdf', pdf: pdf); } }
0
mirrored_repositories/pdf_generate
mirrored_repositories/pdf_generate/lib/main.dart
import 'package:flutter/material.dart'; import 'file_handle_api.dart'; import 'pdf_invoice_api.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( debugShowCheckedModeBanner: false, home: HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( title: const Text('Invoice'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Icons.picture_as_pdf, size: 72.0, color: Colors.white, ), const SizedBox(height: 15.0), const Text( 'Generate Invoice', style: TextStyle( color: Colors.white, fontSize: 25.0, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 30.0), ElevatedButton( child: const Padding( padding: EdgeInsets.symmetric(horizontal: 60.0, vertical: 8.0), child: Text( 'Invoice PDF', style: TextStyle( color: Colors.black, fontSize: 16.0, fontWeight: FontWeight.w600, ), ), ), onPressed: () async { // generate pdf file final pdfFile = await PdfInvoiceApi.generate(); // opening the pdf file FileHandleApi.openFile(pdfFile); }, ), ], ), ), ); } }
0
mirrored_repositories/pdf_generate
mirrored_repositories/pdf_generate/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pdf_generate/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MainApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/gohash_mobile_app
mirrored_repositories/gohash_mobile_app/lib/functions.dart
import 'dart:async'; import 'package:flutter/services.dart'; copyToClipboard(String value, {bool clearAfterTimeout = false, Duration clearTimeout = const Duration(seconds: 60)}) { Clipboard.setData(ClipboardData(text: value)); if (clearAfterTimeout) { Future.delayed(clearTimeout, () async { final data = await Clipboard.getData('text/plain'); if (data?.text == value) { Clipboard.setData(ClipboardData(text: '')); } }); } }
0
mirrored_repositories/gohash_mobile_app
mirrored_repositories/gohash_mobile_app/lib/widgets.dart
import 'package:flutter/material.dart'; import 'package:gohash_mobile/gohash_mobile.dart'; import 'package:gohash_mobile_app/functions.dart'; import 'package:url_launcher/url_launcher.dart'; const _boldFont = TextStyle(fontWeight: FontWeight.bold); class LoginInfoWidget extends StatelessWidget { final LoginInfo _loginInfo; LoginInfoWidget(this._loginInfo); @override Widget build(BuildContext context) { return ListTile( trailing: Icon(Icons.description), onTap: () => _showPopup(context), title: Row(children: [ Text(_loginInfo.name), CopierIcon(Icons.person, _loginInfo.username, onCopiedMessage: 'Username copied!'), CopierIcon(Icons.vpn_key, _loginInfo.password, onCopiedMessage: 'Password copied!' '\nIt will be cleared after one minute.', clearAfterTimeout: true), ])); } _showPopup(BuildContext context) { showDialog( context: context, builder: (ctx) => SimpleDialog( contentPadding: EdgeInsets.all(10.0), children: [ Text('Username:', style: _boldFont), Text(_loginInfo.username), Text('URL:', style: _boldFont), Hyperlink(_loginInfo.url) ..tapCallback = copyToClipboard(_loginInfo.password, clearAfterTimeout: true), Text('Last changed:', style: _boldFont), Text("${_loginInfo.updatedAt}"), Text('Description:', style: _boldFont), Text(_loginInfo.description), ], )); } } class CopierIcon extends StatelessWidget { final String value; final bool clearAfterTimeout; final String onCopiedMessage; final IconData iconData; CopierIcon(IconData icon, String value, {String onCopiedMessage, bool clearAfterTimeout = false}) : this.value = value, this.iconData = icon, this.onCopiedMessage = onCopiedMessage, this.clearAfterTimeout = clearAfterTimeout; @override Widget build(BuildContext context) { return GestureDetector( onTap: () { copyToClipboard(value, clearAfterTimeout: clearAfterTimeout); Scaffold .of(context) .showSnackBar(SnackBar(content: Text(onCopiedMessage))); }, child: Container( padding: EdgeInsets.only(left: 10.0), child: Icon(iconData))); } } const hyperlinkStyle = TextStyle(color: Colors.blue, decoration: TextDecoration.underline); class Hyperlink extends StatelessWidget { final String text; GestureTapCallback tapCallback; Hyperlink(String text) : this.text = _toLink(text); static String _toLink(String value) { if (value.isEmpty) { // no value, can't make up any links return ''; } if (value.startsWith(RegExp('http:|https:|tel:|sms:|mailto:'))) { // this is most likely a link already return value; } // make it a link return "https://$value"; } _onTap() async { launch(text); if (tapCallback != null) { tapCallback(); } } @override Widget build(BuildContext context) { if (text.isEmpty) { return const Text(''); } return GestureDetector( child: Text(text, style: hyperlinkStyle), onTap: _onTap, ); } }
0
mirrored_repositories/gohash_mobile_app
mirrored_repositories/gohash_mobile_app/lib/main.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:gohash_mobile/gohash_mobile.dart'; import 'package:gohash_mobile_app/widgets.dart'; import 'package:path_provider/path_provider.dart'; import 'dart:io'; const _biggerFont = TextStyle(fontSize: 18.0); void main() => runApp(new GoHashApp()); class GoHashApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'go-hash', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new HomePage(title: 'go-hash'), ); } } class HomePage extends StatefulWidget { HomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State<HomePage> { String _errorMessage = ''; GohashDb _database; int _selectedGroupIndex; @override initState() { super.initState(); initPlatformState(); } /// Temporary function to read a go-hash database from assets, writing it /// to a file in the Documents dir, where it's accessible to Go code. Future<File> _loadDbFile() async { final dbBytes = await rootBundle.load('assets/gohash_db'); final docsDir = await getApplicationDocumentsDirectory(); final destinationFile = File("${docsDir.path}/gohash_db"); destinationFile.createSync(); return destinationFile.writeAsBytes(dbBytes.buffer.asUint8List()); } // Platform messages are asynchronous, so we initialize in an async method. initPlatformState() async { GohashDb database = const GohashDb('', []); var errorMessage = ''; final dbFile = await _loadDbFile(); // Platform messages may fail, so we use a try/catch PlatformException. try { database = await GohashMobile.getDb(dbFile.absolute.path, 'secret_password'); errorMessage = ''; } on PlatformException { errorMessage = 'Platform error'; } on MissingPluginException { // method is missing errorMessage = 'Internal app error - missing method'; } on Error catch (e) { errorMessage = 'Error reading go-hash database: $e'; } // If the widget was removed from the tree while the asynchronous platform // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) return; setState(() { _errorMessage = errorMessage; _database = database; _selectedGroupIndex = 0; }); } Widget _buildGroupBody(Group group) { return Column( children: group.entries.map((e) => new LoginInfoWidget(e)).toList()); } ExpansionPanel _buildGroup(int index, Group group) { return ExpansionPanel( headerBuilder: (ctx, isExpanded) => Text( group.name, textAlign: TextAlign.start, style: _biggerFont, ), isExpanded: index == _selectedGroupIndex, body: _buildGroupBody(group)); } Widget _buildGroups() { if (_database == null || _database.groups.isEmpty) { return Text( 'Empty go-hash database', style: _biggerFont, ); } final panels = _database.groups .asMap() .map((index, group) => MapEntry(index, _buildGroup(index, group))); return ExpansionPanelList( children: panels.values.toList(), expansionCallback: (index, isExpanded) => setState(() => _selectedGroupIndex = index)); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(title: Text('go-hash')), body: _errorMessage.isEmpty ? SingleChildScrollView( child: SafeArea( child: Material( child: _buildGroups(), ), ), ) : Center( child: Text("Error: $_errorMessage", style: _biggerFont.apply(color: Colors.red))), )); } }
0
mirrored_repositories/gohash_mobile_app
mirrored_repositories/gohash_mobile_app/test/widget_test.dart
// This is a basic Flutter widget test. // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to // find child widgets in the widget tree, read text, and verify that the values of widget properties // are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:gohash_mobile_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(new GoHashApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/medicare-apps
mirrored_repositories/medicare-apps/lib/main.dart
import 'package:flutter/material.dart'; import 'package:medicalthemeapp/widgets/bottom_nav_bar.dart'; void main() => runApp(const MaterialApp( home: MyApp(), debugShowCheckedModeBanner: false, )); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override State<MyApp> createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return const Scaffold( body: MainBottomNavBar(), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/widgets/emoticonswidgets.dart
// import 'package:flutter/material.dart'; // class EmoticonsWidgets extends StatelessWidget { // const EmoticonsWidgets({Key? key}) : super(key: key); // @override // Widget build(BuildContext context) { // return SingleChildScrollView( // scrollDirection: Axis.horizontal, // child: Row( // children: [ // designCard('🤒', 'temperature'), // const SizedBox( // width: 20, // ), // designCard('🤧', 'snuffle'), // const SizedBox( // width: 20, // ), // designCard('🤕', 'headache'), // const SizedBox( // width: 20, // ), // designCard('😷', 'flu'), // const SizedBox( // width: 20, // ), // ], // )); // } // Widget designCard(String icon, String sympotmsName) => Container( // child: ElevatedButton( // // color: Colors.white70, // // shape: RoundedRectangleBorder( // // borderRadius: BorderRadius.circular(15), // // ), // onPressed: () {}, // child: Padding( // padding: const EdgeInsets.all(10.0), // child: Row( // children: [ // Text( // icon, // style: TextStyle(fontSize: 20), // ), // const SizedBox( // width: 10, // ), // Text( // sympotmsName, // style: TextStyle(fontSize: 20, color: Colors.black87), // ), // ], // ), // ), // ), // ); // }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/widgets/top_doctors_widget.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class TopDoctorsLits extends StatelessWidget { final String firstName; final String lastName; final String rating; final String docCategoryName; final String docImgpath; final String imgPath; const TopDoctorsLits({ Key? key, required this.firstName, required this.lastName, required this.rating, required this.docCategoryName, required this.imgPath, required this.docImgpath, }) : super(key: key); @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(10)), height: 120, child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.all(5), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // rating Row( children: [ Icon( Icons.star, color: Colors.yellow.shade700, size: 10, ), Icon( Icons.star, color: Colors.yellow.shade700, size: 10, ), Icon( Icons.star, color: Colors.yellow.shade700, size: 10, ), Icon( Icons.star, color: Colors.yellow.shade700, size: 10, ), Icon( Icons.star_half, color: Colors.yellow.shade700, size: 10, ), const SizedBox(width: 10), Text( rating, style: GoogleFonts.poppins(fontSize: 10), ) ], ), const SizedBox(height: 5), // name Text(firstName, style: GoogleFonts.ubuntu( fontWeight: FontWeight.bold, fontSize: 15)), Text(lastName, style: GoogleFonts.ubuntu( fontWeight: FontWeight.bold, fontSize: 15)), const SizedBox(height: 10), //category icon & name Row( children: [ Image.asset(imgPath, height: 15), const SizedBox(width: 5), Text( docCategoryName, style: GoogleFonts.ubuntu(fontSize: 13), ) ], ), ], ), ), Column( children: [ Image.asset( docImgpath, height: 60, ), Padding( padding: const EdgeInsets.all(8.0), child: Container( height: 35, width: 35, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.blue, ), child: IconButton( icon: const Icon( Icons.arrow_forward_rounded, size: 20, color: Colors.white, ), onPressed: () {}, ), ), ), ], ) ], ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/widgets/populardoctorwidgets.dart
// import 'package:flutter/material.dart'; // class PopularDoctorWidgets extends StatelessWidget { // const PopularDoctorWidgets({Key? key}) : super(key: key); // @override // Widget build(BuildContext context) { // return GridView.count( // scrollDirection: Axis.vertical, // physics: NeverScrollableScrollPhysics(), // shrinkWrap: true, // crossAxisCount: 2, // children: [ // popularDoctorCard( // 'https://img.icons8.com/external-victoruler-linear-colour-victoruler/344/external-doctor-medical-staff-characters-victoruler-linear-colour-victoruler-5.png', // 'Dr. Chris Evan', // 'Allergists', // '5.0'), // popularDoctorCard( // 'https://img.icons8.com/external-victoruler-linear-colour-victoruler/344/external-doctor-medical-staff-characters-victoruler-linear-colour-victoruler-12.png', // 'Dr. Helena', // 'Therapist', // '4.9'), // popularDoctorCard( // 'https://img.icons8.com/external-victoruler-linear-colour-victoruler/344/external-dentist-medical-staff-characters-victoruler-linear-colour-victoruler.png', // 'Dr. Sultana Parvin', // 'Dentist', // '4.6'), // popularDoctorCard( // 'https://img.icons8.com/external-victoruler-linear-colour-victoruler/344/external-doctor-medical-staff-characters-victoruler-linear-colour-victoruler-6.png', // 'Dr. Abdul Baker', // 'Surgeon', // '4.5'), // popularDoctorCard( // 'https://img.icons8.com/external-victoruler-linear-colour-victoruler/344/external-doctor-medical-staff-characters-victoruler-linear-colour-victoruler-7.png', // 'Dr. Jaden Jordan', // 'Cardiologists', // '4.5'), // popularDoctorCard( // 'https://img.icons8.com/external-victoruler-linear-colour-victoruler/344/external-doctor-medical-staff-characters-victoruler-linear-colour-victoruler-14.png', // 'Dr. Hafsa Akter', // 'Gynecologists', // '4.2'), // ], // ); // } // Widget popularDoctorCard( // String image, String name, String department, String rating) => // Padding( // padding: const EdgeInsets.all(4.0), // child: SizedBox( // height: 150, // width: 150, // child: ElevatedButton( // style: ElevatedButton.styleFrom( // primary: Colors.white, // onPrimary: Colors.blueAccent, // elevation: 8, // shape: RoundedRectangleBorder( // borderRadius: BorderRadius.circular(10)), // ), // onPressed: () {}, // child: Column( // mainAxisAlignment: MainAxisAlignment.spaceEvenly, // children: [ // CircleAvatar( // radius: 40, // child: Image.network(image), // ), // Text( // name, // style: TextStyle(color: Colors.black), // ), // Text( // department, // style: TextStyle(color: Colors.grey), // ), // Container( // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(10), // color: Colors.deepOrange[50], // ), // width: 60, // child: Padding( // padding: const EdgeInsets.all(2), // child: Row( // mainAxisAlignment: MainAxisAlignment.spaceAround, // children: [ // Icon( // Icons.star, // color: Colors.orange, // ), // Text( // rating, // style: TextStyle( // fontWeight: FontWeight.bold, // fontSize: 15, // color: Colors.black), // ) // ], // ), // ), // ) // ], // ), // ), // ), // ); // }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/widgets/introwidgets.dart
// import 'package:flutter/material.dart'; // class IntroWidgets extends StatelessWidget { // final icon; // final String title; // final String subtitle; // const IntroWidgets( // {Key? key, // required this.icon, // required this.title, // required this.subtitle}) // : super(key: key); // @override // Widget build(BuildContext context) { // return SizedBox( // height: 180, // width: 200, // child: Card( // // color: Colors.lime, // elevation: 5, // shape: RoundedRectangleBorder( // borderRadius: BorderRadius.circular(20), // ), // // color: Colors.deepPurple, // child: Padding( // padding: const EdgeInsets.all(10.0), // child: Column( // mainAxisAlignment: MainAxisAlignment.spaceAround, // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // // Icon( // // icon, // // size: 50, // // ), // CircleAvatar( // child: Icon(icon, size: 35,color: Colors.white,), // backgroundColor: Colors.deepPurpleAccent, // ), // Container( // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // Text( // title, // style: TextStyle(fontSize: 25), // ), // Text( // subtitle, // style: TextStyle(fontSize: 15, color: Colors.black38), // ), // ], // ), // ), // ], // ), // ), // ), // ); // } // }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/widgets/bottom_nav_bar.dart
import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:medicalthemeapp/pages/home_page.dart'; import 'package:medicalthemeapp/utils/colors.dart'; import '../utils/user_profile_bar.dart'; class MainBottomNavBar extends StatefulWidget { const MainBottomNavBar({Key? key}) : super(key: key); @override State<MainBottomNavBar> createState() => _MainBottomNavBarState(); } class _MainBottomNavBarState extends State<MainBottomNavBar> { var _selectIndex = 0; final List<Widget> _list = [ const HomePage(), const Text("02"), const Text("03"), const Text("04"), ]; @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, backgroundColor: CustomsColors.backgroundColor, bottomNavigationBar: CurvedNavigationBar( backgroundColor: CustomsColors.backgroundColor, animationDuration: const Duration(milliseconds: 300), items: const [ Icon( Icons.home_max_outlined, ), Icon(Icons.calendar_month_sharp), Icon(Icons.message_outlined), Icon(Icons.person_2_rounded), ], onTap: (index) { setState(() { _selectIndex = index; }); }, ), body: SafeArea( child: Column( children: [ const UserProfilebar(), Expanded(child: _list[_selectIndex]) ], ), ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/widgets/category_widgetss.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class CategoryWidgets extends StatelessWidget { final VoidCallback ontap; final String categoryName; final String imagePath; const CategoryWidgets({ Key? key, required this.ontap, required this.categoryName, required this.imagePath, }) : super(key: key); @override Widget build(BuildContext context) { return Column( children: [ GestureDetector( onTap: ontap, child: Container( height: 60, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white), child: Padding( padding: const EdgeInsets.all(15.0), child: Image.asset(imagePath), ), ), ), const SizedBox(height: 5), Text(categoryName, style: GoogleFonts.ubuntu(fontSize: 17)) ], ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/pages/home_page.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import '../widgets/category_widgetss.dart'; import '../widgets/top_doctors_widget.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { return SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(24.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // search box TextField( decoration: InputDecoration( fillColor: Colors.white, filled: true, border: OutlineInputBorder( borderRadius: BorderRadius.circular(10), borderSide: BorderSide.none), prefixIcon: const Icon( Icons.search, color: Colors.grey, ), hintText: "Search", hintStyle: GoogleFonts.ubuntu(color: Colors.grey), ), ), const SizedBox(height: 25), // categories Text("Category", style: GoogleFonts.poppins(fontSize: 20)), const SizedBox(height: 5), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ CategoryWidgets( categoryName: 'Heart', imagePath: 'assets/categoryIcons/heart.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Eye', imagePath: 'assets/categoryIcons/eye.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Dental', imagePath: 'assets/categoryIcons/teeth.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Blood', imagePath: 'assets/categoryIcons/blood.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Medicine', imagePath: 'assets/categoryIcons/caduceus.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Brain', imagePath: 'assets/categoryIcons/brain.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Nose', imagePath: 'assets/categoryIcons/nose.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Pregnancy', imagePath: 'assets/categoryIcons/pregnant.png', ontap: () {}), const SizedBox(width: 20), CategoryWidgets( categoryName: 'Stomach', imagePath: 'assets/categoryIcons/stomach.png', ontap: () {}), const SizedBox(width: 20), ], ), ), const SizedBox(height: 25), // top doctors Text("Top Doctors", style: GoogleFonts.poppins(fontSize: 20)), const SizedBox(height: 5), SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: const [ TopDoctorsLits( firstName: 'Dr. Robert', lastName: 'Alber', docCategoryName: 'Brain', imgPath: 'assets/categoryIcons/brain.png', rating: '4.5', docImgpath: 'assets/doctorIcons/doctor01.png', ), SizedBox(width: 20), TopDoctorsLits( firstName: 'Dr. Ana', lastName: 'Aslan', docCategoryName: 'Pregnancy', imgPath: 'assets/categoryIcons/pregnant.png', rating: '4.5', docImgpath: 'assets/doctorIcons/doctor02.png', ), SizedBox(width: 20), TopDoctorsLits( firstName: 'Dr. John', lastName: 'kaber', docCategoryName: 'Dental', imgPath: 'assets/categoryIcons/teeth.png', rating: '4.5', docImgpath: 'assets/doctorIcons/doctor03.png', ), SizedBox(width: 20), TopDoctorsLits( firstName: 'Dr. Rubina', lastName: 'Sharmin', docCategoryName: 'Blood', imgPath: 'assets/categoryIcons/blood.png', rating: '4.5', docImgpath: 'assets/doctorIcons/doctor04.png', ), ], ), ), ], ), ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/pages/signup_page.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:medicalthemeapp/pages/login_page.dart'; import 'package:medicalthemeapp/utils/buttons.dart'; import 'package:medicalthemeapp/utils/textform.dart'; import '../utils/colors.dart'; class SignUpPage extends StatefulWidget { const SignUpPage({Key? key}) : super(key: key); @override State<SignUpPage> createState() => _SignUpPageState(); } class _SignUpPageState extends State<SignUpPage> { // DateTime? _selectedDate = DateTime.now(); // //Method for showing the date picker // void _pickDateDialog() { // showDatePicker( // context: context, // initialDate: DateTime.now(), // //which date will display when user open the picker // firstDate: DateTime(1950), // //what will be the previous supported year in picker // lastDate: DateTime // .now()) //what will be the up to supported date in picker // .then((pickedDate) { // //then usually do the future job // if (pickedDate == null) { // //if user tap cancel then this function will stop // return; // } // setState(() { // //for rebuilding the ui // _selectedDate = pickedDate; // }); // }); // } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: CustomsColors.backgroundColor, body: SafeArea( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(24.0), child: Column( // mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ // sign up text Text('Sign up ', style: GoogleFonts.poppins(fontSize: 40)), const SizedBox(height: 30), // email section const MyTextFields( introText: 'Enter your Email', hintText: "[email protected]", textInputType: TextInputType.emailAddress, ), const SizedBox(height: 15), // password section const MyTextFields( introText: 'Enter your password', obscure: true), const SizedBox(height: 15), // mobile number section const MyTextFields( introText: 'Enter Mobile Number', hintText: '01xxxxxxxxx', textInputType: TextInputType.number, ), const SizedBox(height: 30), // date of birth section // ElevatedButton( // onPressed: _pickDateDialog, // child: const Padding( // padding: EdgeInsets.all(6), // child: Text("Select your birthday"), // ), // ), // Text(_selectedDate.toString(), // style: const TextStyle(color: Colors.black, fontSize: 20)), // const SizedBox(height: 15), // sign up button MyButton( text: 'Continue', ontap: () { setState(() { Navigator.pushAndRemoveUntil( context, MaterialPageRoute( builder: (context) => const LoginPage()), (route) => false); }); }), const SizedBox(height: 30), // already have account Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Already our member?", style: GoogleFonts.comfortaa(color: Colors.black38)), // const SizedBox(width: 5), TextButton( onPressed: () { setState(() { Navigator.push( context, MaterialPageRoute( builder: (context) => const LoginPage())); }); }, child: Text('Login', style: GoogleFonts.comfortaa(color: Colors.blue.shade400)), ), ], ) ], ), ), )), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/pages/splash_screen.dart
import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:medicalthemeapp/widgets/bottom_nav_bar.dart'; class SplashScreen extends StatefulWidget { const SplashScreen({Key? key}) : super(key: key); @override State<SplashScreen> createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { Timer( const Duration(seconds: 3), () => Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => const MainBottomNavBar()), (route) => false)); return Scaffold( body: Center( child: SvgPicture.asset( 'assets/splash.svg', fit: BoxFit.fill, ), ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/pages/home.dart
// import 'package:flutter/material.dart'; // import 'package:medicalthemeapp/widgets/emoticonswidgets.dart'; // import 'package:medicalthemeapp/widgets/introwidgets.dart'; // import 'package:medicalthemeapp/widgets/populardoctorwidgets.dart'; // class HomePage extends StatefulWidget { // const HomePage({Key? key}) : super(key: key); // @override // State<HomePage> createState() => _HomePageState(); // } // class _HomePageState extends State<HomePage> { // @override // Widget build(BuildContext context) { // return SafeArea( // child: ListView( // // shrinkWrap: true, // children: [ // Padding( // padding: const EdgeInsets.all(20.0), // child: Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: [ // Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // // name and hi sign // Column( // crossAxisAlignment: CrossAxisAlignment.start, // children: const [ // Text( // "Saon Sikder 👋", // style: TextStyle( // fontSize: 25, fontWeight: FontWeight.bold), // ), // Text( // 'Dhaka, Bangladesh', // style: TextStyle(color: Colors.blueGrey), // ) // ], // ), // // profile icon // CircleAvatar( // radius: 25, // child: Image.network( // 'https://img.icons8.com/external-others-cattaleeya-thongsriphong/2x/external-Man-male-avatar-color-line-others-cattaleeya-thongsriphong-14.png'), // ) // ], // ), // const SizedBox(height: 20), // // clinic visit card // SingleChildScrollView( // scrollDirection: Axis.horizontal, // child: Row( // children: const [ // IntroWidgets( // icon: Icons.add_circle, // title: 'Clinic Visit', // subtitle: 'Make an appointment'), // IntroWidgets( // icon: Icons.home_filled, // title: 'Home Visit', // subtitle: 'Call the doctor home'), // IntroWidgets( // icon: Icons.factory_outlined, // title: 'Office Visit', // subtitle: 'Call the medical team office'), // IntroWidgets( // icon: Icons.local_hospital_outlined, // title: 'Emergency Visit', // subtitle: 'Get instant services'), // ], // ), // ), // const SizedBox(height: 20), // // what are your symptoms // const Text( // 'What are your symptoms?', // style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), // ), // const SizedBox(height: 20), // const EmoticonsWidgets(), // const SizedBox(height: 30), // // popular doctors // const Text( // 'Popular doctors', // style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), // ), // const SizedBox(height: 20), // PopularDoctorWidgets(), // ], // ), // ), // ]), // ); // } // }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/pages/login_page.dart
import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:medicalthemeapp/pages/signup_page.dart'; import 'package:medicalthemeapp/utils/colors.dart'; import 'package:medicalthemeapp/widgets/bottom_nav_bar.dart'; import '../utils/buttons.dart'; import '../utils/square_box.dart'; import '../utils/textform.dart'; class LoginPage extends StatefulWidget { const LoginPage({Key? key}) : super(key: key); @override State<LoginPage> createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { final GlobalKey<FormState> _key = GlobalKey<FormState>(); @override Widget build(BuildContext context) { return Scaffold( // resizeToAvoidBottomInset: false, backgroundColor: CustomsColors.backgroundColor, body: Center( child: SingleChildScrollView( child: SafeArea( child: Padding( padding: const EdgeInsets.all(24.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // medicare text and icon Row( mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( 'assets/medicon.svg', height: 40, ), const SizedBox(width: 10), Text("MediCare", style: GoogleFonts.comfortaa(fontSize: 30)), ], ), const SizedBox(height: 60), // email part const MyTextFields( introText: 'Your email address', hintText: '[email protected]', ), const SizedBox(height: 5), // password part const MyTextFields( introText: 'Your password', obscure: true, ), // forgot password Row( mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( onPressed: () {}, child: Text("forgot password !!", style: GoogleFonts.comfortaa( color: Colors.blue.shade400))), ], ), const SizedBox(height: 20), // login button MyButton( text: 'Login', ontap: () { setState(() { Navigator.push( context, MaterialPageRoute( builder: (context) => const MainBottomNavBar())); }); }, ), const SizedBox(height: 20), Row( children: [ const Expanded( child: Divider( thickness: 1, ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 12), child: Text("Or connect with", style: GoogleFonts.comfortaa(color: Colors.grey)), ), const Expanded( child: Divider( thickness: 1, ), ), ], ), const SizedBox(height: 20), // alternative account login Row( mainAxisAlignment: MainAxisAlignment.center, children: const [ SquareBox(imagePath: 'assets/google.svg'), SizedBox(width: 15), SquareBox(imagePath: 'assets/apple_logo.svg'), ]), const SizedBox(height: 50), // don't our member? Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Don't our member?", style: GoogleFonts.comfortaa(color: Colors.black38)), // const SizedBox(width: 5), TextButton( onPressed: () { setState(() { setState(() { Navigator.push( context, MaterialPageRoute( builder: (context) => const SignUpPage())); }); }); }, child: Text('Be our Member', style: GoogleFonts.comfortaa( color: Colors.blue.shade400)), ), ], ) ], ), )), ), ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/utils/user_profile_bar.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class UserProfilebar extends StatelessWidget { final VoidCallback? ontap; const UserProfilebar({ Key? key, this.ontap, }) : super(key: key); @override Widget build(BuildContext context) { return ListTile( onTap: ontap, tileColor: Colors.green.shade100, title: Text( 'Hello', style: GoogleFonts.comfortaa(fontSize: 15), ), subtitle: Text("Nick Jonas, 23", style: GoogleFonts.comfortaa(fontSize: 20, fontWeight: FontWeight.bold)), leading: CircleAvatar( maxRadius: 20, child: Image.asset('assets/man.png'), ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/utils/textform.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class MyTextFields extends StatelessWidget { final String introText; final String? hintText; final bool? obscure; final TextInputType? textInputType; const MyTextFields({ Key? key, required this.introText, this.hintText, this.obscure, this.textInputType, }) : super(key: key); @override Widget build(BuildContext context) { return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(introText, style: GoogleFonts.jost(fontSize: 20)), const SizedBox(height: 10), TextField( keyboardType: textInputType ?? TextInputType.text, obscureText: obscure ?? false, decoration: InputDecoration( hintText: hintText ?? '', hintStyle: GoogleFonts.quicksand(), fillColor: Colors.green.shade100, filled: true, border: OutlineInputBorder(borderRadius: BorderRadius.circular(10))), ), ]); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/utils/square_box.dart
import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; class SquareBox extends StatelessWidget { final String imagePath; const SquareBox({ required this.imagePath, Key? key, }) : super(key: key); @override Widget build(BuildContext context) { return GestureDetector( onTap: () {}, child: Container( height: 60, width: 60, padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.blue.shade100, border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10)), child: SvgPicture.asset(imagePath), ), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/utils/colors.dart
import 'package:flutter/material.dart'; class CustomsColors { static Color backgroundColor = const Color(0xffe5f2ff); }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/utils/buttons.dart
import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class MyButton extends StatelessWidget { final String text; final VoidCallback ontap; const MyButton({ Key? key, required this.text, required this.ontap, }) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( height: 40, width: double.infinity, child: ElevatedButton( onPressed: ontap, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text(text), const SizedBox(width: 20), ], ), style: ElevatedButton.styleFrom( backgroundColor: Colors.blue.shade100, foregroundColor: Colors.black, textStyle: GoogleFonts.comfortaa(fontWeight: FontWeight.bold), )), ); } }
0
mirrored_repositories/medicare-apps/lib
mirrored_repositories/medicare-apps/lib/utils/fonts.dart
import 'package:google_fonts/google_fonts.dart'; class MyFonts { static GoogleFonts fonts = GoogleFonts.comfortaa() as GoogleFonts; }
0
mirrored_repositories/medicare-apps
mirrored_repositories/medicare-apps/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:medicalthemeapp/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib/main.dart
import 'package:bloc_sample/screens/cart_screen.dart'; import 'package:bloc_sample/screens/product_list_screen.dart'; import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // TODO: implement build return MaterialApp( debugShowCheckedModeBanner: false, routes: { "/": (BuildContext context) => ProductListScreen(), "/cart": (BuildContext context) => CartScreen(), }, initialRoute: "/", ); } }
0
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib/blocs/product_bloc.dart
import 'dart:async'; import 'package:bloc_sample/data/product_service.dart'; import 'package:bloc_sample/models/product.dart'; class ProductBloc { final productStreamController = StreamController.broadcast(); Stream get getStream => productStreamController.stream; List<Product> getAll() { return ProductService.getAll(); } } final productBloc = ProductBloc();
0
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib/blocs/cart_bloc.dart
import 'dart:async'; import 'package:bloc_sample/data/cart_service.dart'; import 'package:bloc_sample/models/cart.dart'; class CartBloc { final cartStreamController = StreamController.broadcast(); Stream get getStream => cartStreamController.stream; void addToCart(Cart item) { CartService.addToCart(item); cartStreamController.sink.add(CartService.getCart()); } void removeFromCart(Cart item) { CartService.removeFromCart(item); cartStreamController.sink.add(CartService.getCart()); } List<Cart> getCart() { return CartService.getCart(); } } final cartBloc = CartBloc();
0
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib/models/cart.dart
import 'package:bloc_sample/models/product.dart'; class Cart { Product product; int quantity; Cart(this.product, this.quantity); }
0
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib
mirrored_repositories/Mobile-Programming-Lecture-Notes/Bloc-Sample-Shopping-Flutter-Project-main/bloc_sample/lib/models/product.dart
class Product { int id; String name; double price; Product(this.id, this.name, this.price); }
0