Skip to content

Instantly share code, notes, and snippets.

@oluyoung
Created May 17, 2024 01:44
Show Gist options
  • Save oluyoung/8fcbd3699e5305f2c0d29d2c0665abb1 to your computer and use it in GitHub Desktop.
Save oluyoung/8fcbd3699e5305f2c0d29d2c0665abb1 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
primarySwatch: Colors.green,
),
home: OrderDetailPage(),
);
}
}
class OrderDetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Current Order Detail'),
leading: BackButton(),
actions: [
IconButton(
icon: Icon(Icons.more_vert),
onPressed: () {},
),
],
),
body: ListView(
padding: EdgeInsets.all(16.0),
children: [
_buildOrderInfoCard(),
SizedBox(height: 16.0),
_buildProductDetailsCard(),
SizedBox(height: 16.0),
_buildDriverInfoCard(),
SizedBox(height: 16.0),
_buildLocationCard(),
SizedBox(height: 16.0),
_buildOrderTrackingCard(),
SizedBox(height: 16.0),
_buildBillDetailsCard(),
],
),
bottomNavigationBar: SafeArea(
child: Padding(
padding: EdgeInsets.all(16.0),
child: ElevatedButton(
onPressed: () {},
child: Text('Track Order'),
style: ElevatedButton.styleFrom(
primary: Colors.green,
padding: EdgeInsets.symmetric(vertical: 16.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
),
),
);
}
Widget _buildOrderInfoCard() {
return Card(
child: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Order ID', style: TextStyle(color: Colors.grey)),
Text('23568463C', style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold)),
SizedBox(height: 8.0),
Text('Payment Mode', style: TextStyle(color: Colors.grey)),
Text('Cash on Delivery', style: TextStyle(fontSize: 16.0)),
SizedBox(height: 8.0),
Text('Date', style: TextStyle(color: Colors.grey)),
Text('6 Dec, 2022 20:50', style: TextStyle(fontSize: 16.0)),
],
),
),
);
}
Widget _buildProductDetailsCard() {
return Card(
child: Padding(
padding: EdgeInsets.all(16.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.network(
'https://placehold.co/64x64?description=Product%20Image',
width: 64.0,
height: 64.0,
),
SizedBox(width: 16.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Brake Pad', style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold)),
SizedBox(height: 8.0),
Text('₦12,000.00', style: TextStyle(fontSize: 16.0, color: Colors.green)),
SizedBox(height: 8.0),
Text('6 Dec, 2022 / 08:50pm', style: TextStyle(color: Colors.grey)),
SizedBox(height: 8.0),
Text('Qty: 1', style: TextStyle(fontSize: 16.0)),
],
),
),
],
),
),
);
}
Widget _buildDriverInfoCard() {
return Card(
child: ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage('https://placehold.co/40x40?description=Driver%20Image'),
),
title: Text('Tokunbo Babajide'),
subtitle: Text('613 555 0140'),
trailing: IconButton(
icon: Icon(Icons.phone, color: Colors.green),
onPressed: () {},
),
),
);
}
Widget _buildLocationCard() {
return Card(
child: ListTile(
leading: Icon(Icons.location_on, color: Colors.green),
title: Text('12 Obafemi Idowu street, Ikeja, Lagos'),
),
);
}
Widget _buildOrderTrackingCard() {
return Card(
child: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
children: [
_buildTrackingStep('Order Placed', '11:38AM, 6 January, 2022', true),
_buildTrackingStep('Shipped', '7 January, 2022', true),
_buildTrackingStep('Order Delivered', '8 January, 2022', false),
],
),
),
);
}
Widget _buildTrackingStep(String title, String subtitle, bool isCompleted) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: [
Column(
children: [
Icon(
Icons.circle,
color: isCompleted ? Colors.green : Colors.grey,
size: 16.0,
),
if (title != 'Order Delivered')
Container(
height: 24.0,
width: 1.0,
color: Colors.grey,
margin: EdgeInsets.symmetric(vertical: 4.0),
),
],
),
SizedBox(width: 16.0),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold)),
Text(subtitle, style: TextStyle(color: Colors.grey)),
],
),
),
],
),
);
}
Widget _buildBillDetailsCard() {
return Card(
child: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildBillDetailRow('Sub Total', '₦12,000.00'),
_buildBillDetailRow('Coupon Discount', '₦0', isDiscount: true),
_buildBillDetailRow('Delivery Fee', '₦1,000.00'),
Divider(),
_buildBillDetailRow('Total Amount', '₦13,000.00', isTotal: true),
],
),
),
);
}
Widget _buildBillDetailRow(String title, String amount, {bool isDiscount = false, bool isTotal = false}) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(title, style: TextStyle(fontSize: 16.0, color: isTotal ? Colors.black : Colors.grey)),
Text(amount, style: TextStyle(fontSize: 16.0, color: isDiscount ? Colors.red : Colors.black, fontWeight: isTotal ? FontWeight.bold : FontWeight.normal)),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment