Update project
This commit is contained in:
@@ -277,17 +277,8 @@ class _AccountPageState extends State<AccountPage> {
|
||||
}
|
||||
},
|
||||
),
|
||||
_divider(),
|
||||
_tile(
|
||||
icon: Icons.question_answer,
|
||||
title: "Faq",
|
||||
onTap: () => Get.to(
|
||||
() => FaqView(),
|
||||
// transition: Transition.fade, // or any transition you like
|
||||
// duration: Duration(milliseconds: 400),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
_divider(),
|
||||
_tile(
|
||||
icon: Icons.reorder,
|
||||
@@ -318,15 +309,15 @@ class _AccountPageState extends State<AccountPage> {
|
||||
onTap: controller.rateApp,
|
||||
),
|
||||
_divider(),
|
||||
// _tile(
|
||||
// icon: Icons.group_add,
|
||||
// title: "Refer a Friend",
|
||||
// onTap: () => Get.to(
|
||||
// () => const ShowContactsScreen(),
|
||||
// // transition: Transition.fade, // or any style you like
|
||||
// // duration: Duration(milliseconds: 400),
|
||||
// ),
|
||||
// ),
|
||||
_tile(
|
||||
icon: Icons.group_add,
|
||||
title: "Refer a Friend",
|
||||
onTap: () => Get.to(
|
||||
() => ReferEarnScreen(),
|
||||
// transition: Transition.fade, // or any style you like
|
||||
// duration: Duration(milliseconds: 400),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -347,6 +338,17 @@ class _AccountPageState extends State<AccountPage> {
|
||||
// duration: Duration(milliseconds: 400),
|
||||
),
|
||||
|
||||
),
|
||||
_divider(),
|
||||
_tile(
|
||||
icon: Icons.question_answer,
|
||||
title: "Faq",
|
||||
onTap: () => Get.to(
|
||||
() => FaqView(),
|
||||
// transition: Transition.fade, // or any transition you like
|
||||
// duration: Duration(milliseconds: 400),
|
||||
),
|
||||
|
||||
),
|
||||
_divider(),
|
||||
_tile(
|
||||
|
||||
@@ -1,379 +1,396 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_contacts/flutter_contacts.dart';
|
||||
// import 'package:nearledaily/constants/color_constants.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart'
|
||||
// as permission_handler;
|
||||
// import 'package:url_launcher/url_launcher.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
//
|
||||
// import '../../constants/font_constants.dart';
|
||||
// import '../../widgets/text_widget.dart';
|
||||
//
|
||||
// class ShowContactsScreen extends StatefulWidget {
|
||||
// const ShowContactsScreen({super.key});
|
||||
//
|
||||
// @override
|
||||
// State<ShowContactsScreen> createState() => _ShowContactsScreenState();
|
||||
// }
|
||||
//
|
||||
// class _ShowContactsScreenState extends State<ShowContactsScreen>
|
||||
// with WidgetsBindingObserver {
|
||||
// List<Contact> _contacts = [];
|
||||
// bool _loading = false;
|
||||
// bool _permissionDenied = false;
|
||||
//
|
||||
// /// 🔹 ADDED
|
||||
// bool _showDisclaimer = true;
|
||||
//
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// WidgetsBinding.instance.addObserver(this);
|
||||
// _loadContacts();
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void dispose() {
|
||||
// WidgetsBinding.instance.removeObserver(this);
|
||||
// super.dispose();
|
||||
// }
|
||||
//
|
||||
// Future<void> _loadContacts() async {
|
||||
// setState(() {
|
||||
// _loading = true;
|
||||
// _permissionDenied = false;
|
||||
// });
|
||||
//
|
||||
// final bool granted = await FlutterContacts.requestPermission();
|
||||
//
|
||||
// if (!granted) {
|
||||
// setState(() {
|
||||
// _loading = false;
|
||||
// _permissionDenied = true;
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// final List<Contact> contacts = await FlutterContacts.getContacts(
|
||||
// withProperties: true,
|
||||
// withPhoto: true,
|
||||
// );
|
||||
//
|
||||
// setState(() {
|
||||
// _contacts = contacts
|
||||
// .where((c) => c.phones.isNotEmpty)
|
||||
// .toList()
|
||||
// ..sort((a, b) => a.displayName.compareTo(b.displayName));
|
||||
// _loading = false;
|
||||
// });
|
||||
// } catch (e) {
|
||||
// setState(() {
|
||||
// _loading = false;
|
||||
// });
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// content: ReusableTextWidget(
|
||||
// text: "Error loading contacts: $e",
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Widget _buildAvatar(Contact contact) {
|
||||
// if (contact.photo != null && contact.photo!.isNotEmpty) {
|
||||
// return CircleAvatar(
|
||||
// backgroundImage: MemoryImage(contact.photo!),
|
||||
// );
|
||||
// } else {
|
||||
// String initials = "";
|
||||
// final names = contact.displayName.split(" ");
|
||||
// if (names.isNotEmpty) initials += names[0][0];
|
||||
// if (names.length > 1) initials += names[1][0];
|
||||
// return CircleAvatar(
|
||||
// backgroundColor: Colors.primaries[
|
||||
// contact.displayName.hashCode % Colors.primaries.length],
|
||||
// child: ReusableTextWidget(
|
||||
// text: initials.toUpperCase(),
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<void> _openWhatsApp(Contact contact) async {
|
||||
// if (contact.phones.isEmpty) return;
|
||||
//
|
||||
// String phoneNumber =
|
||||
// contact.phones.first.number.replaceAll(RegExp(r'\D'), '');
|
||||
// final Uri url = Uri.parse("https://wa.me/$phoneNumber");
|
||||
//
|
||||
// if (await canLaunchUrl(url)) {
|
||||
// await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||
// } else {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: ReusableTextWidget(
|
||||
// text: "Could not open WhatsApp",
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<void> _inviteWhatsApp(Contact contact) async {
|
||||
// if (contact.phones.isEmpty) return;
|
||||
//
|
||||
// String phoneNumber =
|
||||
// contact.phones.first.number.replaceAll(RegExp(r'\D'), '');
|
||||
//
|
||||
// final String message = Uri.encodeComponent(
|
||||
// "Hey! Join me on Nearle Daily 🚀");
|
||||
//
|
||||
// final Uri url = Uri.parse("https://wa.me/$phoneNumber?text=$message");
|
||||
//
|
||||
// if (await canLaunchUrl(url)) {
|
||||
// await launchUrl(url, mode: LaunchMode.externalApplication);
|
||||
// } else {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// const SnackBar(
|
||||
// content: ReusableTextWidget(
|
||||
// text: "Could not open WhatsApp",
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
// value: const SystemUiOverlayStyle(
|
||||
// statusBarColor: Colors.white, // White background
|
||||
// statusBarIconBrightness: Brightness.dark, // Dark icons
|
||||
// statusBarBrightness: Brightness.light, // iOS
|
||||
// ),
|
||||
// child: Scaffold(
|
||||
// backgroundColor: Colors.white,
|
||||
// appBar: AppBar(
|
||||
// backgroundColor: Colors.white,
|
||||
// surfaceTintColor: Colors.transparent,
|
||||
// scrolledUnderElevation: 0,
|
||||
// titleSpacing: -5,
|
||||
// animateColor: false,
|
||||
// elevation: 0,
|
||||
// title: ReusableTextWidget(
|
||||
// text: "Refer a friend",
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// iconTheme: const IconThemeData(color: Colors.black),
|
||||
// ),
|
||||
// body: Padding(
|
||||
// padding: const EdgeInsets.only(left: 12.0, right: 12, bottom: 12),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// /// 🔹 MODIFIED DISCLAIMER ONLY
|
||||
// if (_showDisclaimer)
|
||||
// Stack(
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(top: 12.0),
|
||||
// child: Container(
|
||||
// width: double.infinity,
|
||||
// padding: const EdgeInsets.all(14),
|
||||
// margin: const EdgeInsets.only(bottom: 16),
|
||||
// decoration: BoxDecoration(
|
||||
// color: ColorConstants.primaryColor.withOpacity(0.08),
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// ),
|
||||
// child: const ReusableTextWidget(
|
||||
// text:
|
||||
// "We access contacts only to let you share\nor recommend to friends. Nothing is stored.",
|
||||
// fontSize: 13,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.black87,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Positioned(
|
||||
// top: 6,
|
||||
// right: -3,
|
||||
// child: IconButton(
|
||||
// icon: const Icon(Icons.close, size: 18),
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// _showDisclaimer = false;
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
//
|
||||
// if (_loading)
|
||||
// const Expanded(
|
||||
// child: Center(child: CircularProgressIndicator()),
|
||||
// ),
|
||||
//
|
||||
// if (_permissionDenied)
|
||||
// Expanded(
|
||||
// child: Center(
|
||||
// child: Container(
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 24),
|
||||
// padding: const EdgeInsets.all(24),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.red.withOpacity(0.05),
|
||||
// borderRadius: BorderRadius.circular(20),
|
||||
// border: Border.all(
|
||||
// color: Colors.red.withOpacity(0.2),
|
||||
// ),
|
||||
// ),
|
||||
// child: Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Container(
|
||||
// padding: const EdgeInsets.all(18),
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.red.withOpacity(0.12),
|
||||
// shape: BoxShape.circle,
|
||||
// ),
|
||||
// child: const Icon(
|
||||
// Icons.info_outline,
|
||||
// color: Colors.red,
|
||||
// size: 48,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 20),
|
||||
// const ReusableTextWidget(
|
||||
// text: "Contacts Access Needed",
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// const ReusableTextWidget(
|
||||
// text:
|
||||
// "Allow contacts permission to view\nand invite your friends easily.",
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.black54,
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// const SizedBox(height: 24),
|
||||
// SizedBox(
|
||||
// width: double.infinity,
|
||||
// child: ElevatedButton(
|
||||
// onPressed: permission_handler.openAppSettings,
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: Colors.red,
|
||||
// elevation: 0,
|
||||
// padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// ),
|
||||
// ),
|
||||
// child: const ReusableTextWidget(
|
||||
// text: "Open Settings",
|
||||
// fontSize: 15,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// if (_contacts.isNotEmpty && !_loading && !_permissionDenied)
|
||||
// Expanded(
|
||||
// child: RefreshIndicator(
|
||||
// onRefresh: _loadContacts,
|
||||
// child: ListView.builder(
|
||||
// itemCount: _contacts.length,
|
||||
// itemBuilder: (context, index) {
|
||||
// final contact = _contacts[index];
|
||||
// final phones =
|
||||
// contact.phones.map((p) => p.number).toList();
|
||||
// final subtitle = phones.length > 1
|
||||
// ? phones.sublist(0, 2).join(", ")
|
||||
// : phones.first;
|
||||
//
|
||||
// return ListTile(
|
||||
// leading: _buildAvatar(contact),
|
||||
// title: ReusableTextWidget(
|
||||
// text: contact.displayName.isEmpty
|
||||
// ? "No Name"
|
||||
// : contact.displayName,
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// subtitle: ReusableTextWidget(
|
||||
// text: subtitle,
|
||||
// fontSize: 13,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// trailing: TextButton(
|
||||
// onPressed: () => _inviteWhatsApp(contact),
|
||||
// child: const ReusableTextWidget(
|
||||
// text: "Invite",
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.green,
|
||||
// ),
|
||||
// ),
|
||||
// onTap: () => _openWhatsApp(contact),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// if (_contacts.isEmpty && !_loading && !_permissionDenied)
|
||||
// const Expanded(
|
||||
// child: Center(
|
||||
// child: ReusableTextWidget(
|
||||
// text: "No contacts found with phone numbers",
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w400,
|
||||
// fontFamily: FontConstants.fontFamily,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../constants/color_constants.dart';
|
||||
import '../../constants/font_constants.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ReferEarnScreen (StatefulWidget)
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
class ReferEarnScreen extends StatefulWidget {
|
||||
const ReferEarnScreen({super.key});
|
||||
|
||||
@override
|
||||
State<ReferEarnScreen> createState() => _ReferEarnScreenState();
|
||||
}
|
||||
|
||||
class _ReferEarnScreenState extends State<ReferEarnScreen> {
|
||||
bool _codeCopied = false;
|
||||
|
||||
static const String _referralCode = 'ANBU123';
|
||||
static const int _totalCoins = 1250;
|
||||
|
||||
|
||||
// ── helpers ────────────────────────────────────────────────────────────────
|
||||
void _copyCode() async {
|
||||
await Clipboard.setData(const ClipboardData(text: _referralCode));
|
||||
setState(() => _codeCopied = true);
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
if (mounted) setState(() => _codeCopied = false);
|
||||
}
|
||||
|
||||
|
||||
// ── build ──────────────────────────────────────────────────────────────────
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: true,
|
||||
child: Scaffold(
|
||||
backgroundColor: Color(0xFFF6F6F6),
|
||||
appBar: AppBar(
|
||||
|
||||
surfaceTintColor: Colors.transparent,
|
||||
|
||||
// 🔥 Prevent color overlay when scrolled
|
||||
scrolledUnderElevation: 0,
|
||||
animateColor: false, // ✨ prevent color change on scroll
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.white,
|
||||
|
||||
leading: const BackButton(color: Color(0xFF1A1A2E)),
|
||||
|
||||
title: ReusableTextWidget(
|
||||
text: 'Refer & Earn',
|
||||
color: const Color(0xFF1A1A2E),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 11, vertical: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildTotalCoinsBanner(),
|
||||
const SizedBox(height: 16),
|
||||
_buildReferralCodeCard(),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
Center(
|
||||
child: ReusableTextWidget(
|
||||
text: 'How It Works',
|
||||
color: const Color(0xFF1A1A2E),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
_buildHowItWorksRow(),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Total Coins Banner ─────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildTotalCoinsBanner() {
|
||||
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
ColorConstants.primaryColor.withOpacity(0.85),
|
||||
ColorConstants.primaryColor,
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ReusableTextWidget(
|
||||
text: 'Total Coins',
|
||||
color: Colors.white,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ReusableTextWidget(
|
||||
text: '$_totalCoins Coins',
|
||||
color: Colors.white,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w800,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ReusableTextWidget(
|
||||
text: 'Earn more by referring friends',
|
||||
color: Colors.white60,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 80,
|
||||
height: 70,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.white.withOpacity(0.15),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text('🪙', style: TextStyle(fontSize: 36)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Referral Code Card ─────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildReferralCodeCard() {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ReusableTextWidget(
|
||||
text: 'Your Referral Code',
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
width: 1.5),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ReusableTextWidget(
|
||||
text: _referralCode,
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: _copyCode,
|
||||
child: AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: _codeCopied
|
||||
? Row(
|
||||
key: const ValueKey('copied'),
|
||||
children: [
|
||||
const Icon(Icons.check_circle,
|
||||
size: 18, color: Color(0xFF2ECC71)),
|
||||
const SizedBox(width: 4),
|
||||
ReusableTextWidget(
|
||||
text: 'Copied!',
|
||||
color: const Color(0xFF2ECC71),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
key: const ValueKey('copy'),
|
||||
children: [
|
||||
Icon(Icons.copy,
|
||||
size: 18,
|
||||
color: ColorConstants.primaryColor),
|
||||
const SizedBox(width: 4),
|
||||
ReusableTextWidget(
|
||||
text: 'Copy',
|
||||
color: ColorConstants.primaryColor,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {},
|
||||
icon: const Icon(Icons.share_rounded, color: Colors.white),
|
||||
label: ReusableTextWidget(
|
||||
text: 'Invite Friends & Earn',
|
||||
color: Colors.white,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
elevation: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: ReusableTextWidget(
|
||||
text: 'Share your code or link with friends',
|
||||
color: Colors.grey,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ── How It Works ───────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildHowItWorksRow() {
|
||||
final steps = [
|
||||
{
|
||||
'step': 1,
|
||||
'icon': Icons.share_rounded,
|
||||
'label': 'Share',
|
||||
'color': ColorConstants.primaryColor,
|
||||
},
|
||||
{
|
||||
'step': 2,
|
||||
'icon': Icons.download_rounded,
|
||||
'label': 'Install',
|
||||
'color': const Color(0xFF3498DB),
|
||||
},
|
||||
{
|
||||
'step': 3,
|
||||
'icon': Icons.how_to_reg_rounded,
|
||||
'label': 'Register',
|
||||
'color': const Color(0xFF2ECC71),
|
||||
},
|
||||
{
|
||||
'step': 4,
|
||||
'icon': Icons.card_giftcard_rounded,
|
||||
'label': 'Reward',
|
||||
'color': const Color(0xFFE67E22),
|
||||
},
|
||||
];
|
||||
|
||||
return Row(
|
||||
children: steps.map((s) {
|
||||
final color = s['color'] as Color;
|
||||
|
||||
return Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
width: 42,
|
||||
height: 42,
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.12),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
s['icon'] as IconData,
|
||||
color: color,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: -3,
|
||||
left: -3,
|
||||
child: Container(
|
||||
width: 16,
|
||||
height: 16,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${s['step']}',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 8,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ReusableTextWidget(
|
||||
text: s['label'] as String,
|
||||
color: const Color(0xFF555555),
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.w600,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
@@ -13,7 +14,8 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../constants/color_constants.dart';
|
||||
import '../../constants/font_constants.dart';
|
||||
import '../../controllers/tenant_controller /tenant_list.dart';
|
||||
import '../../controllers/tenant_list/tenant_controller.dart';
|
||||
import '../../service/firebase_analytics/analytics_service.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
import '../home_view.dart';
|
||||
|
||||
@@ -114,6 +116,19 @@ class _CustomerCreateViewState extends State<CustomerCreateView> {
|
||||
await prefs.setString('customerDoorNo', details['doorno'] ?? '');
|
||||
|
||||
debugPrint("✅ Customer info saved to SharedPreferences.");
|
||||
|
||||
await FirebaseAnalytics.instance.setUserId(
|
||||
id: customerIdStr,
|
||||
);
|
||||
|
||||
await AnalyticsService.logEvent(
|
||||
'signup_success',
|
||||
parameters: {
|
||||
'customer_id': int.tryParse(customerIdStr) ?? 0,
|
||||
'customer_name': details['firstname'] ?? '',
|
||||
'user_type': 'new_user',
|
||||
},
|
||||
);
|
||||
}
|
||||
tenantController.loadTenants();
|
||||
|
||||
@@ -131,11 +146,7 @@ class _CustomerCreateViewState extends State<CustomerCreateView> {
|
||||
fontSize: 15,
|
||||
);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
// ❌ Handle failure message from API
|
||||
debugPrint("❌ API returned failure: $message");
|
||||
|
||||
@@ -147,8 +158,6 @@ class _CustomerCreateViewState extends State<CustomerCreateView> {
|
||||
textColor: Colors.white,
|
||||
fontSize: 15,
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
} catch (e, stacktrace) {
|
||||
debugPrint(" Something went wrong");
|
||||
@@ -161,17 +170,11 @@ class _CustomerCreateViewState extends State<CustomerCreateView> {
|
||||
textColor: Colors.white,
|
||||
fontSize: 15,
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
|
||||
|
||||
final size = MediaQuery.of(context).size;
|
||||
final width = size.width;
|
||||
final height = size.height;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
import '../../controllers/authentication/auth_controller.dart';
|
||||
import '../../service/firebase_analytics/analytics_service.dart';
|
||||
import '../authentication/verification_view.dart';
|
||||
|
||||
class Login_view extends StatelessWidget {
|
||||
@@ -319,8 +320,13 @@ class Login_view extends StatelessWidget {
|
||||
elevation: 0,
|
||||
),
|
||||
onPressed: canProceed
|
||||
? () =>
|
||||
authController.signIn(context, phone)
|
||||
? () async {
|
||||
await AnalyticsService.logEvent(
|
||||
'login_continue_clicked',
|
||||
);
|
||||
|
||||
authController.signIn(context, phone);
|
||||
}
|
||||
: null,
|
||||
child: authController.isLoading.value
|
||||
? const SizedBox(
|
||||
|
||||
@@ -347,13 +347,39 @@ class _CartPageState extends State<CartPage> {
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
'No slots available for today.\nPlease try changing dates to schedule orders.',
|
||||
'Your cart is empty.\nBrowse our products to get started.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 46,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
// Switch to the Stores tab (index 1) via the shared GetX controller
|
||||
Get.find<BottomNavController>().currentIndex.value = 1;
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: ColorConstants.primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'Browse Products',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import '../../constants/font_constants.dart';
|
||||
import '../../controllers/cart_controller/cart.dart';
|
||||
import '../../controllers/order_controller/create_order_controller.dart';
|
||||
import '../../modules/orders/create_order.dart';
|
||||
import '../../service/firebase_analytics/analytics_service.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
import '../orders/order_succes.dart';
|
||||
|
||||
@@ -99,12 +100,25 @@ class _OrderCountdownPageState extends State<OrderCountdownPage>
|
||||
|
||||
|
||||
if (!widget.orderCtrl.isLoading.value) {
|
||||
|
||||
await AnalyticsService.logEvent(
|
||||
'order_placed',
|
||||
parameters: {
|
||||
'customer_id': widget.order.customerid ?? 0,
|
||||
'tenant_id': widget.order.tenantid ?? 0,
|
||||
'item_count': widget.order.items?.length ?? 0,
|
||||
'payment_type': widget.order.paymenttype ?? 0,
|
||||
},
|
||||
);
|
||||
|
||||
Get.offAll(() => OrderSuccessView());
|
||||
widget.cartCtrl.clearCart();
|
||||
await widget.cartCtrl.notifyAdmin(
|
||||
title: 'Nearle Deals - New Order',
|
||||
body: 'A new order has been placed successfully by ${widget.customerName}!',
|
||||
);
|
||||
print('jeee');
|
||||
print(widget.order.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1625
lib/view/dashboard_view/ai_search.dart
Normal file
1625
lib/view/dashboard_view/ai_search.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:animated_text_kit/animated_text_kit.dart';
|
||||
import 'package:animations/animations.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -27,8 +28,12 @@ import '../../controllers/cart_controller/cart.dart';
|
||||
import '../../controllers/dashboard_controller/category.dart';
|
||||
import '../../controllers/dashboard_controller/dashboard_controller.dart';
|
||||
import '../../controllers/product/product_controller.dart';
|
||||
import '../../controllers/tenant_controller /tenant_list.dart';
|
||||
import '../../controllers/tenant_list/tenant_controller.dart';
|
||||
import '../../domain/repository/authentication/auth_repository.dart';
|
||||
import '../../features/Products/product_card.dart';
|
||||
import '../../modules/search_model/search_model.dart';
|
||||
import '../../service/firebase_analytics/analytics_service.dart';
|
||||
import '../../widgets/fav_button.dart';
|
||||
import '../../widgets/tenantcategory.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
import '../account/demo.dart';
|
||||
@@ -37,8 +42,10 @@ import '../cart/cart_view.dart';
|
||||
import '../home_view.dart';
|
||||
import '../product/category_products.dart';
|
||||
import '../product/product_view.dart';
|
||||
import '../product/products_list.dart' hide ProductItem;
|
||||
import '../product/tenant_products.dart';
|
||||
import '../qr_scaner/qr_scaner.dart';
|
||||
import 'ai_search.dart';
|
||||
|
||||
class DashboardPage extends StatefulWidget {
|
||||
const DashboardPage({super.key});
|
||||
@@ -72,6 +79,87 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
static const _kProfile = 'cached_profile';
|
||||
|
||||
|
||||
final recommendations = [
|
||||
RecommendedItem(
|
||||
title: 'Cheapest Pizza\nNearby',
|
||||
subtitle: 'From ₹149',
|
||||
image: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS9b5A0dGeZ4PR6cdpuvDyoMa3lO7JBRyMo8Q&s',
|
||||
bgColor: Color(0xFFFFF3EC),
|
||||
accentColor: Color(0xFFFF6B2C),
|
||||
),
|
||||
RecommendedItem(
|
||||
title: 'Grocery Basket\n₹320 Less',
|
||||
subtitle: 'Save more on your order',
|
||||
image: 'https://images.unsplash.com/photo-1542838132-92c53300491e?w=200&fit=crop',
|
||||
bgColor: Color(0xFFF0FAF0),
|
||||
accentColor: Color(0xFF22A45D),
|
||||
),
|
||||
RecommendedItem(
|
||||
title: 'Birthday\nComing Up!',
|
||||
subtitle: 'Let Nearle plan it',
|
||||
image: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=200&fit=crop',
|
||||
bgColor: Color(0xFFFDF0F8),
|
||||
accentColor: Color(0xFFD63384),
|
||||
),
|
||||
];
|
||||
|
||||
final products = [
|
||||
ProductItem(
|
||||
name: 'Chicken Biryani',
|
||||
category: 'Food · HotPot',
|
||||
price: '₹189',
|
||||
originalPrice: '₹240',
|
||||
image: 'https://images.unsplash.com/photo-1563379091339-03b21ab4a4f8?w=300&fit=crop',
|
||||
rating: 4.8,
|
||||
reviewCount: 320,
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Fresh Veggie Basket',
|
||||
category: 'Grocery · BigBasket',
|
||||
price: '₹299',
|
||||
originalPrice: '₹420',
|
||||
image: 'https://images.unsplash.com/photo-1512621776951-a57141f2eefd?w=300&fit=crop',
|
||||
rating: 4.5,
|
||||
reviewCount: 180,
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Margherita Pizza',
|
||||
category: 'Food · Dominos',
|
||||
price: '₹149',
|
||||
originalPrice: '₹199',
|
||||
image: 'https://images.unsplash.com/photo-1565299624946-b28f40a0ae38?w=300&fit=crop',
|
||||
rating: 4.6,
|
||||
reviewCount: 512,
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Birthday Cake',
|
||||
category: 'Bakery · CakeZone',
|
||||
price: '₹549',
|
||||
originalPrice: '₹699',
|
||||
image: 'https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=300&fit=crop',
|
||||
rating: 4.9,
|
||||
reviewCount: 94,
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Mango Smoothie',
|
||||
category: 'Drinks · Juice Bar',
|
||||
price: '₹89',
|
||||
originalPrice: '₹120',
|
||||
image: 'https://images.unsplash.com/photo-1623065422902-30a2d299bbe4?w=300&fit=crop',
|
||||
rating: 4.4,
|
||||
reviewCount: 67,
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Paneer Butter Masala',
|
||||
category: 'Food · Behrouz',
|
||||
price: '₹220',
|
||||
originalPrice: '₹280',
|
||||
image: 'https://images.unsplash.com/photo-1631452180519-c014fe946bc7?w=300&fit=crop',
|
||||
rating: 4.7,
|
||||
reviewCount: 210,
|
||||
),
|
||||
];
|
||||
|
||||
bool status = true;
|
||||
bool _showBackToTop = false;
|
||||
RxBool showMiniCart = false.obs;
|
||||
@@ -84,177 +172,6 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
Icons.shopping_cart_rounded,
|
||||
];
|
||||
|
||||
void _openCategoryBottomSheet(
|
||||
BuildContext context,
|
||||
List subCategories,
|
||||
item,
|
||||
) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (_) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: ClipRRect(
|
||||
borderRadius:
|
||||
const BorderRadius.vertical(top: Radius.circular(20)),
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.85,
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// drag handle (smaller)
|
||||
Container(
|
||||
width: 36,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade400,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Title (not oversized)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 14),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Category",
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
Expanded(
|
||||
child: subCategories.isEmpty
|
||||
? const Center(
|
||||
child: Text("No products available"),
|
||||
)
|
||||
: GridView.builder(
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(12, 8, 12, 16),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 0.78,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
),
|
||||
itemCount: subCategories.length,
|
||||
itemBuilder: (context, index) {
|
||||
final product = subCategories[index];
|
||||
|
||||
return InkWell(
|
||||
borderRadius:
|
||||
BorderRadius.circular(14),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Get.to(
|
||||
() => SubCategoryProductsScreen(
|
||||
tenantId: item.tenantid!,
|
||||
locationId: item.locationid!,
|
||||
categoryId: item.categoryid!,
|
||||
tenantName: item.tenantname!,
|
||||
locationname:
|
||||
item.locationname!,
|
||||
tenantLocation: item.suburb!,
|
||||
tenantImage:
|
||||
item.tenantimage!,
|
||||
tenantloc:
|
||||
item.locationid!,
|
||||
subCategoryName:
|
||||
product.subcatname
|
||||
.toString(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.circular(14),
|
||||
border: Border.all(
|
||||
color: Colors.black12,
|
||||
width: 0.25,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black
|
||||
.withOpacity(0.04),
|
||||
blurRadius: 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
ClipOval(
|
||||
child: Image.network(
|
||||
product.image ?? '',
|
||||
width: 100,
|
||||
height: 100,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder:
|
||||
(_, __, ___) =>
|
||||
const Icon(
|
||||
Icons
|
||||
.image_not_supported),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 6),
|
||||
child: ReusableTextWidget(
|
||||
text:
|
||||
product.subcatname ??
|
||||
'',
|
||||
color: Colors.black
|
||||
.withOpacity(0.7),
|
||||
fontFamily:
|
||||
FontConstants
|
||||
.fontFamily,
|
||||
fontSize: 11.5,
|
||||
fontWeight:
|
||||
FontWeight.w600,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow
|
||||
.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
@@ -659,7 +576,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: () => Get.to(() => const SearchScreen()),
|
||||
child: Container(
|
||||
height: 48,
|
||||
height: 55,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
@@ -710,6 +627,11 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
IconButton(onPressed: () => Get.to(() => const SearchPage()), icon: const Icon(Icons.mic, color: Colors.black87, size: 22)),
|
||||
|
||||
|
||||
IconButton(onPressed: () => Get.to(() => const SearchPage()), icon: const Icon(Icons.camera_alt_outlined, color: Colors.black87, size: 22)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -811,12 +733,226 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
);
|
||||
}),
|
||||
|
||||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 12),
|
||||
),
|
||||
|
||||
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Recommended for You",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text("See all"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: 110,
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: recommendations.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(width: 12),
|
||||
itemBuilder: (context, index) {
|
||||
final item = recommendations[index];
|
||||
|
||||
return Container(
|
||||
width: 160,
|
||||
decoration: BoxDecoration(
|
||||
color: item.bgColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
|
||||
// Title + Subtitle
|
||||
Positioned(
|
||||
top: 14,
|
||||
left: 14,
|
||||
right: 14,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.title,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
height: 1.25,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
item.subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: item.accentColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Network image bottom-right
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomRight: Radius.circular(20),
|
||||
),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: item.image,
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.contain,
|
||||
placeholder: (context, url) => const SizedBox(
|
||||
width: 80,
|
||||
height: 80,
|
||||
),
|
||||
errorWidget: (context, url, error) => SizedBox(
|
||||
width: 80,
|
||||
height: 80,
|
||||
child: Icon(
|
||||
Icons.image_not_supported_rounded,
|
||||
color: item.accentColor.withOpacity(0.3),
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Arrow button bottom-right corner
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: 10,
|
||||
child: Container(
|
||||
width: 26,
|
||||
height: 26,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.08),
|
||||
blurRadius: 6,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
Icons.chevron_right_rounded,
|
||||
size: 16,
|
||||
color: item.accentColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 12),
|
||||
),
|
||||
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Fresh picks for you",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context,) => const ProductsList()));
|
||||
},
|
||||
child: const Text("See all"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 12),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
mainAxisExtent: 270,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => ProductCard(item: products[index]),
|
||||
childCount: products.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 12),
|
||||
),
|
||||
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Near by Stores",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black.withOpacity(0.7),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text("See all"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
@@ -898,7 +1034,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
(context, index) {
|
||||
final item = tenantController.tenants[index];
|
||||
return _ZoomOnTap(
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
Get.to(() => ProductsScreen(
|
||||
tenantId: item.tenantid!,
|
||||
locationId: item.locationid!,
|
||||
@@ -910,6 +1046,16 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
tenantloc:item.locationid!,
|
||||
subCategoryName: "",
|
||||
));
|
||||
|
||||
await AnalyticsService.logEvent(
|
||||
'store_viewed',
|
||||
parameters: {
|
||||
'store_id': item.tenantid!,
|
||||
'store_name': item.tenantname!,
|
||||
'locatiom' : item.locationname!,
|
||||
},
|
||||
);
|
||||
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 12, top: 12),
|
||||
@@ -1063,7 +1209,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
maxLines: 1,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
// _openCategoryBottomSheet(
|
||||
// context,
|
||||
// item.subcategories ?? [],
|
||||
@@ -1082,6 +1228,15 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
subCategoryName: "",
|
||||
));
|
||||
|
||||
await AnalyticsService.logEvent(
|
||||
'store_viewed',
|
||||
parameters: {
|
||||
'store_id': item.tenantid!,
|
||||
'store_name': item.tenantname!,
|
||||
'locatiom' : item.locationname!,
|
||||
},
|
||||
);
|
||||
|
||||
},
|
||||
icon: Icon(Icons.arrow_circle_right_outlined,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
@@ -1113,7 +1268,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
final product = item.subcategories![index];
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
|
||||
// Get.to(() => SubCategoryProductsScreen(
|
||||
// tenantId: item.tenantid!,
|
||||
@@ -1139,6 +1294,15 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
subCategoryName: "",
|
||||
));
|
||||
|
||||
await AnalyticsService.logEvent(
|
||||
'store_viewed',
|
||||
parameters: {
|
||||
'store_id': item.tenantid!,
|
||||
'store_name': item.tenantname!,
|
||||
'locatiom' : item.locationname!,
|
||||
},
|
||||
);
|
||||
|
||||
},
|
||||
child: Container(
|
||||
margin:
|
||||
@@ -1247,11 +1411,6 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Obx(() {
|
||||
if (cartController.cartItems.isEmpty) return const SizedBox();
|
||||
final tenant = cartController.currentTenant.value;
|
||||
@@ -1374,45 +1533,12 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
],),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _chip(String emoji, String label) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFF8F4FF),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
border: Border.all(color: Color(0xFFE0D4FF), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(emoji, style: TextStyle(fontSize: 13)),
|
||||
SizedBox(width: 5),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w500, color: Color(0xFF333333)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1628,23 +1754,6 @@ class _DashboardPageState extends State<DashboardPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBannerShimmer() {
|
||||
return SliverToBoxAdapter(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey.shade300,
|
||||
highlightColor: Colors.grey.shade100,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
height: 180,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListShimmer(BuildContext context) {
|
||||
return SliverList(
|
||||
@@ -1834,4 +1943,5 @@ class _ZoomOnTapState extends State<_ZoomOnTap> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -81,6 +81,210 @@ class TenantApiService {
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// SHIMMER WIDGET
|
||||
// ─────────────────────────────────────────────
|
||||
class _ShimmerBox extends StatefulWidget {
|
||||
final double width;
|
||||
final double height;
|
||||
final double borderRadius;
|
||||
|
||||
const _ShimmerBox({
|
||||
required this.width,
|
||||
required this.height,
|
||||
this.borderRadius = 8,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_ShimmerBox> createState() => _ShimmerBoxState();
|
||||
}
|
||||
|
||||
class _ShimmerBoxState extends State<_ShimmerBox>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _animation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 1200),
|
||||
)..repeat();
|
||||
_animation = Tween<double>(begin: -1.5, end: 1.5).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOutSine),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (_, __) => Container(
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(widget.borderRadius),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment(_animation.value - 1, 0),
|
||||
end: Alignment(_animation.value, 0),
|
||||
colors: const [
|
||||
Color(0xFFE8E8E8),
|
||||
Color(0xFFF5F5F5),
|
||||
Color(0xFFE8E8E8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Shimmer skeleton that mimics the actual screen layout
|
||||
class _StoreOverviewShimmer extends StatelessWidget {
|
||||
const _StoreOverviewShimmer();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Top bar
|
||||
Row(
|
||||
children: [
|
||||
_ShimmerBox(width: 40, height: 40, borderRadius: 20),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Store card shimmer
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_ShimmerBox(width: 200, height: 22, borderRadius: 6),
|
||||
const SizedBox(height: 10),
|
||||
_ShimmerBox(width: double.infinity, height: 13, borderRadius: 4),
|
||||
const SizedBox(height: 6),
|
||||
_ShimmerBox(width: 160, height: 13, borderRadius: 4),
|
||||
const SizedBox(height: 14),
|
||||
Row(
|
||||
children: [
|
||||
_ShimmerBox(width: 40, height: 40, borderRadius: 20),
|
||||
const SizedBox(width: 12),
|
||||
_ShimmerBox(width: 40, height: 40, borderRadius: 20),
|
||||
],
|
||||
),
|
||||
const Divider(height: 24, thickness: 0.5),
|
||||
Row(
|
||||
children: [
|
||||
_ShimmerBox(width: 20, height: 20, borderRadius: 4),
|
||||
const SizedBox(width: 12),
|
||||
_ShimmerBox(width: 100, height: 13, borderRadius: 4),
|
||||
],
|
||||
),
|
||||
const Divider(height: 24, thickness: 0.5),
|
||||
Row(
|
||||
children: [
|
||||
_ShimmerBox(width: 20, height: 20, borderRadius: 4),
|
||||
const SizedBox(width: 12),
|
||||
_ShimmerBox(width: 150, height: 13, borderRadius: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Bad experience card shimmer
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
child: Row(
|
||||
children: [
|
||||
_ShimmerBox(width: 36, height: 36, borderRadius: 18),
|
||||
const SizedBox(width: 12),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_ShimmerBox(width: 180, height: 13, borderRadius: 4),
|
||||
const SizedBox(height: 6),
|
||||
_ShimmerBox(width: 140, height: 11, borderRadius: 4),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Legal card shimmer
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.04),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List.generate(4, (i) => Padding(
|
||||
padding: EdgeInsets.only(bottom: i < 3 ? 16.0 : 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_ShimmerBox(width: 80, height: 11, borderRadius: 4),
|
||||
const SizedBox(height: 5),
|
||||
_ShimmerBox(width: 160, height: 13, borderRadius: 4),
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// SCREEN
|
||||
// ─────────────────────────────────────────────
|
||||
@@ -285,9 +489,16 @@ class _StoreOverviewScreenState extends State<StoreOverviewScreen> {
|
||||
child: FutureBuilder<TenantDetails>(
|
||||
future: _future,
|
||||
builder: (context, snap) {
|
||||
// ── SHIMMER while loading ──────────────
|
||||
if (snap.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(child: const _StoreOverviewShimmer()),
|
||||
_bottomButton(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
if (snap.hasError) {
|
||||
return Center(
|
||||
child: Column(
|
||||
|
||||
560
lib/view/dashboard_view/test.dart
Normal file
560
lib/view/dashboard_view/test.dart
Normal file
@@ -0,0 +1,560 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// CONFIG — change IP to your Mac's local IP
|
||||
// Run: ipconfig getifaddr en0
|
||||
// ─────────────────────────────────────────────
|
||||
const String kBaseUrl = 'http://192.168.1.XXX:8000';
|
||||
const int kCustomerId = 6060;
|
||||
const double kLatitude = 11.0168;
|
||||
const double kLongitude = 76.9558;
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// API SERVICE
|
||||
// ─────────────────────────────────────────────
|
||||
class AgentService {
|
||||
static Future<Map<String, dynamic>> findIngredients(String userInput) async {
|
||||
final res = await http.post(
|
||||
Uri.parse('$kBaseUrl/find-ingredients'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'user_input': userInput,
|
||||
'customer_id': kCustomerId,
|
||||
'latitude': kLatitude,
|
||||
'longitude': kLongitude,
|
||||
}),
|
||||
);
|
||||
return jsonDecode(res.body);
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> chat(
|
||||
String message,
|
||||
List conversationHistory,
|
||||
) async {
|
||||
final res = await http.post(
|
||||
Uri.parse('$kBaseUrl/chat'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'message': message,
|
||||
'customer_id': kCustomerId,
|
||||
'latitude': kLatitude,
|
||||
'longitude': kLongitude,
|
||||
'conversation_history': conversationHistory,
|
||||
}),
|
||||
);
|
||||
return jsonDecode(res.body);
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> clarify(
|
||||
String originalInput,
|
||||
String clarification,
|
||||
) async {
|
||||
final res = await http.post(
|
||||
Uri.parse('$kBaseUrl/clarify'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'original_input': originalInput,
|
||||
'clarification': clarification,
|
||||
'customer_id': kCustomerId,
|
||||
'latitude': kLatitude,
|
||||
'longitude': kLongitude,
|
||||
}),
|
||||
);
|
||||
return jsonDecode(res.body);
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// SEARCH SCREEN
|
||||
// ─────────────────────────────────────────────
|
||||
class SearchScreen extends StatefulWidget {
|
||||
const SearchScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SearchScreen> createState() => _SearchScreenState();
|
||||
}
|
||||
|
||||
class _SearchScreenState extends State<SearchScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
|
||||
bool _isLoading = false;
|
||||
String? _agentMessage;
|
||||
String? _clarificationQuestion;
|
||||
String? _lastInput;
|
||||
|
||||
List _ingredients = [];
|
||||
List _stores = [];
|
||||
|
||||
// Quick suggestion chips
|
||||
final List<String> _suggestions = [
|
||||
'🍓 Strawberry',
|
||||
'🍗 Biryani',
|
||||
'🤒 Fever medicine',
|
||||
'🍳 Cook sambar',
|
||||
'🥛 Milk',
|
||||
'😴 Bored snacks',
|
||||
];
|
||||
|
||||
// ── Search via /find-ingredients ──────────────────────────
|
||||
Future<void> _search(String input) async {
|
||||
if (input.trim().isEmpty) return;
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_agentMessage = null;
|
||||
_clarificationQuestion = null;
|
||||
_stores = [];
|
||||
_ingredients = [];
|
||||
_lastInput = input;
|
||||
});
|
||||
|
||||
try {
|
||||
final result = await AgentService.findIngredients(input);
|
||||
|
||||
if (result['status'] == 'needs_clarification') {
|
||||
setState(() {
|
||||
_clarificationQuestion = result['question'];
|
||||
_isLoading = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_agentMessage = result['agent_message'];
|
||||
_ingredients = result['ingredients_needed'] ?? [];
|
||||
_stores = result['stores'] ?? [];
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_agentMessage = 'Something went wrong. Please try again.';
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ── Answer agent clarification ────────────────────────────
|
||||
Future<void> _answerClarification(String answer) async {
|
||||
setState(() {
|
||||
_clarificationQuestion = null;
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
try {
|
||||
final result = await AgentService.clarify(_lastInput ?? '', answer);
|
||||
setState(() {
|
||||
_agentMessage = result['agent_message'];
|
||||
_ingredients = result['ingredients_needed'] ?? [];
|
||||
_stores = result['stores'] ?? [];
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_agentMessage = 'Something went wrong.';
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────
|
||||
// BUILD
|
||||
// ─────────────────────────────────────────────────────────
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F5F5),
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
title: const Text(
|
||||
'Nearle',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1A1A1A),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
// ── Search Bar ──────────────────────────────────
|
||||
Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
focusNode: _focusNode,
|
||||
onSubmitted: _search,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Search or ask anything...',
|
||||
hintStyle: TextStyle(color: Colors.grey[400]),
|
||||
prefixIcon: const Icon(Icons.search, color: Color(0xFF6C63FF)),
|
||||
filled: true,
|
||||
fillColor: const Color(0xFFF0EFFF),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 14),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
GestureDetector(
|
||||
onTap: () => _search(_searchController.text),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF6C63FF),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.arrow_forward, color: Colors.white, size: 20),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// ── Suggestion Chips ────────────────────────────
|
||||
if (_stores.isEmpty && !_isLoading && _clarificationQuestion == null)
|
||||
SizedBox(
|
||||
height: 48,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
itemCount: _suggestions.length,
|
||||
separatorBuilder: (_, __) => const SizedBox(width: 8),
|
||||
itemBuilder: (context, i) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
final text = _suggestions[i].replaceAll(RegExp(r'[^\w\s]'), '').trim();
|
||||
_searchController.text = text;
|
||||
_search(text);
|
||||
},
|
||||
child: Chip(
|
||||
label: Text(
|
||||
_suggestions[i],
|
||||
style: const TextStyle(fontSize: 13),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
side: const BorderSide(color: Color(0xFFE0E0E0)),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// ── Body ────────────────────────────────────────
|
||||
Expanded(
|
||||
child: _isLoading
|
||||
? const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(color: Color(0xFF6C63FF)),
|
||||
SizedBox(height: 16),
|
||||
Text('Anna is finding the best deals...', style: TextStyle(color: Colors.grey)),
|
||||
],
|
||||
),
|
||||
)
|
||||
: _clarificationQuestion != null
|
||||
? _buildClarification()
|
||||
: _stores.isEmpty
|
||||
? _buildEmpty()
|
||||
: _buildResults(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Clarification UI ──────────────────────────────────────
|
||||
Widget _buildClarification() {
|
||||
final answerController = TextEditingController();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEDE9FF),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text('🤔', style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
_clarificationQuestion!,
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: answerController,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Type your answer...',
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none),
|
||||
),
|
||||
onSubmitted: _answerClarification,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => _answerClarification(answerController.text),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF6C63FF),
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
child: const Text('Send', style: TextStyle(color: Colors.white, fontSize: 16)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Empty State ───────────────────────────────────────────
|
||||
Widget _buildEmpty() {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('🛒', style: TextStyle(fontSize: 60)),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
_agentMessage ?? 'Search for anything\nfrom nearby stores',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 16, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Results ───────────────────────────────────────────────
|
||||
Widget _buildResults() {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Agent message
|
||||
if (_agentMessage != null)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEDE9FF),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Text('✨', style: TextStyle(fontSize: 20)),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: Text(_agentMessage!, style: const TextStyle(fontSize: 14))),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Store cards
|
||||
..._stores.map((storeData) => _StoreCard(storeData: storeData)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// STORE CARD WIDGET
|
||||
// ─────────────────────────────────────────────
|
||||
class _StoreCard extends StatelessWidget {
|
||||
final Map storeData;
|
||||
const _StoreCard({required this.storeData});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final store = storeData['store'] as Map;
|
||||
final products = storeData['matched_products'] as List;
|
||||
final savings = store['total_savings'] ?? 0;
|
||||
final total = store['total_discounted_price'] ?? 0;
|
||||
final hasOffers = store['has_offers'] == true;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10, offset: const Offset(0, 2))],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Store header
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF0EFFF),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(Icons.store, color: Color(0xFF6C63FF), size: 20),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
store['tenantname'] ?? '',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
|
||||
),
|
||||
Text(
|
||||
store['locationname'] ?? '',
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 13),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (hasOffers)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE8F5E9),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
'Save ₹${savings.toStringAsFixed(0)}',
|
||||
style: const TextStyle(color: Color(0xFF2E7D32), fontWeight: FontWeight.bold, fontSize: 12),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Divider(height: 1),
|
||||
|
||||
// Products
|
||||
...products.map((m) => _ProductRow(matched: m)),
|
||||
|
||||
const Divider(height: 1),
|
||||
|
||||
// Total + Order button
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text('Total', style: TextStyle(color: Colors.grey, fontSize: 12)),
|
||||
Text(
|
||||
'₹${total.toStringAsFixed(2)}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Color(0xFF1A1A1A)),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF6C63FF),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: const Text('Order Now', style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// PRODUCT ROW WIDGET
|
||||
// ─────────────────────────────────────────────
|
||||
class _ProductRow extends StatelessWidget {
|
||||
final Map matched;
|
||||
const _ProductRow({required this.matched});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final product = matched['product'] as Map;
|
||||
final emoji = matched['emoji'] ?? '🛒';
|
||||
final name = product['productname'] ?? matched['ingredient'] ?? '';
|
||||
final price = product['discounted_price'] ?? 0;
|
||||
final original = product['original_price'] ?? 0;
|
||||
final hasOffer = product['has_offer'] == true;
|
||||
final discount = product['discount_percent'] ?? 0;
|
||||
final quantity = matched['quantity'] ?? '';
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(emoji, style: const TextStyle(fontSize: 24)),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(name, style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 14)),
|
||||
Text(quantity, style: const TextStyle(color: Colors.grey, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'₹${price.toStringAsFixed(2)}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Color(0xFF1A1A1A)),
|
||||
),
|
||||
if (hasOffer)
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'₹${original.toStringAsFixed(0)}',
|
||||
style: const TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 11,
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'$discount% off',
|
||||
style: const TextStyle(color: Color(0xFF2E7D32), fontSize: 11, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import 'package:lottie/lottie.dart';
|
||||
import 'package:nearledaily/view/qr_scaner/qr_scaner.dart';
|
||||
import '../constants/font_constants.dart';
|
||||
import '../controllers/cart_controller/cart.dart';
|
||||
import '../features/Store/presentation/screens/store_view.dart';
|
||||
import '../features/dashboard/presentation/screens/dash_view.dart';
|
||||
import '../widgets/text_widget.dart';
|
||||
import 'account/account_view.dart';
|
||||
import 'cart/cart_view.dart';
|
||||
@@ -22,8 +24,9 @@ const Color _kInactive = Color(0xFFCBA8E4);
|
||||
// ─── Screens ──────────────────────────────────────────────────────────────────
|
||||
|
||||
final List<Widget> _screens = [
|
||||
DashboardPage(),
|
||||
const OrdersByStoreScreen(showBackArrow: false),
|
||||
HomeScreen(),
|
||||
StoreViewPage(),
|
||||
// const OrdersByStoreScreen(showBackArrow: false),
|
||||
QrScannerPage(),
|
||||
CartPage(),
|
||||
AccountPage(),
|
||||
@@ -131,18 +134,29 @@ class BottomNavigation extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
extendBody: true,
|
||||
bottomNavigationBar: Obx(
|
||||
() => _BottomNavBar(
|
||||
currentIndex: controller.currentIndex.value,
|
||||
cartController: cartController,
|
||||
onTap: (i) => controller.currentIndex.value = i,
|
||||
return PopScope(
|
||||
canPop: controller.currentIndex.value == 0,
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (didPop) return;
|
||||
|
||||
// Not on Home tab -> go back to Home instead of exiting/popping
|
||||
if (controller.currentIndex.value != 0) {
|
||||
controller.currentIndex.value = 0;
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
extendBody: true,
|
||||
bottomNavigationBar: Obx(
|
||||
() => _BottomNavBar(
|
||||
currentIndex: controller.currentIndex.value,
|
||||
cartController: cartController,
|
||||
onTap: (i) => controller.currentIndex.value = i,
|
||||
),
|
||||
),
|
||||
body: Obx(
|
||||
() => _screens[controller.currentIndex.value],
|
||||
),
|
||||
),
|
||||
body: Obx(
|
||||
() => _screens[controller.currentIndex.value],
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -240,8 +254,8 @@ class _GlassPill extends StatelessWidget {
|
||||
onTap: () => onTap(0),
|
||||
),
|
||||
_NavItem(
|
||||
icon: Icons.receipt_long_rounded,
|
||||
label: 'Order',
|
||||
icon: Icons.storefront,
|
||||
label: 'Stores',
|
||||
isActive: currentIndex == 1,
|
||||
onTap: () => onTap(1),
|
||||
),
|
||||
@@ -440,4 +454,4 @@ class _CartNavItem extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:nearledaily/constants/color_constants.dart';
|
||||
import '../../../constants/font_constants.dart';
|
||||
import '../../controllers/cart_controller/cart.dart';
|
||||
import '../../controllers/dashboard_controller/dashboard_controller.dart';
|
||||
import '../../features/orders/presentation/order_tracking.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
import '../home_view.dart';
|
||||
|
||||
@@ -233,7 +234,44 @@ class _OrderSuccessViewState extends State<OrderSuccessView>
|
||||
|
||||
SizedBox(height: size.height * 0.015),
|
||||
|
||||
// Secondary CTA — Track Order
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: OutlinedButton(
|
||||
onPressed: () {
|
||||
Get.to(() => DeliveryTrackingPage());
|
||||
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: ColorConstants.primaryColor,
|
||||
side: BorderSide(
|
||||
color: ColorConstants.primaryColor,
|
||||
width: 1.5,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.local_shipping_outlined, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
ReusableTextWidget(
|
||||
text: 'Track Order',
|
||||
color: ColorConstants.primaryColor,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: size.height * 0.015),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import '../../constants/asset_constants.dart';
|
||||
import '../../constants/color_constants.dart';
|
||||
import '../../constants/font_constants.dart';
|
||||
import '../../controllers/tenant/get_tenant.dart'; // OrderedTenantController
|
||||
import '../../features/orders/presentation/order_tracking.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
import 'my_orders.dart'; // OrderDatum
|
||||
|
||||
@@ -450,149 +451,126 @@ class _OrdersByStoreScreenState extends State<OrdersByStoreScreen>
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.spaceBetween,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
final uri = Uri(scheme: 'tel', path: order.pickupcontactno!);
|
||||
if (await canLaunchUrl(uri)) {
|
||||
await launchUrl(uri);
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ReusableTextWidget(
|
||||
text: 'Contact :',
|
||||
color: ColorConstants.blackColor.withOpacity(0.67),
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
// Track Button
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 44,
|
||||
margin: const EdgeInsets.only(right: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF662582), Color(0xFF7A2E9C)],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.phone_rounded,
|
||||
size: 14,
|
||||
color: ColorConstants.primaryColor,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF662582).withOpacity(0.3),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: () {
|
||||
HapticFeedback.mediumImpact();
|
||||
Get.to(() => const DeliveryTrackingPage());
|
||||
},
|
||||
child: const Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.location_on_rounded, color: Colors.white, size: 18),
|
||||
SizedBox(width: 6),
|
||||
Text(
|
||||
'Track',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
ReusableTextWidget(
|
||||
text: order.pickupcontactno ?? "No Contact",
|
||||
color: ColorConstants.primaryColor,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
fontFamily: FontConstants.fontFamily,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
ElevatedButton(
|
||||
style: ElevatedButton
|
||||
.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets
|
||||
.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 5),
|
||||
shape:
|
||||
RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
8),
|
||||
// View Details Button
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: primaryColor, width: 1.4),
|
||||
color: Colors.white,
|
||||
),
|
||||
backgroundColor:
|
||||
primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
// ✨ Haptic feedback on button press
|
||||
HapticFeedback.mediumImpact();
|
||||
|
||||
// ✨ Smooth page transition
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context,
|
||||
animation,
|
||||
secondaryAnimation) =>
|
||||
OrderDetailsPage(
|
||||
orderId: order
|
||||
.orderid ??
|
||||
'Unknown',
|
||||
storeName: tenantName,
|
||||
storeLocation: order
|
||||
.tenantsuburb ??
|
||||
'Unknown',
|
||||
tax: order
|
||||
.totaltaxamount ??
|
||||
0,
|
||||
gstno: order.gstno ?? "",
|
||||
fee: order
|
||||
.deliverycharge ??
|
||||
0,
|
||||
items: order
|
||||
.orderdetails
|
||||
?.map((item) =>
|
||||
{
|
||||
'name':
|
||||
item.productname ?? 'Unknown',
|
||||
'quantity':
|
||||
item.orderqty ?? 0,
|
||||
'productSumPrice':
|
||||
item.productsumprice ?? 0.0,
|
||||
'price':
|
||||
item.price ?? 0.0,
|
||||
'discountamount':
|
||||
item.price ?? 0.0,
|
||||
'image':
|
||||
item.productimage ?? '',
|
||||
})
|
||||
.toList() ??
|
||||
[],
|
||||
),
|
||||
transitionsBuilder:
|
||||
(context,
|
||||
animation,
|
||||
secondaryAnimation,
|
||||
child) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child:
|
||||
SlideTransition(
|
||||
position:
|
||||
Tween<Offset>(
|
||||
begin:
|
||||
const Offset(
|
||||
0.05, 0),
|
||||
end:
|
||||
Offset.zero,
|
||||
).animate(
|
||||
animation),
|
||||
child: child,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
onTap: () {
|
||||
HapticFeedback.mediumImpact();
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation, secondaryAnimation) =>
|
||||
OrderDetailsPage(
|
||||
orderId: order.orderid ?? 'Unknown',
|
||||
storeName: tenantName,
|
||||
storeLocation: order.tenantsuburb ?? 'Unknown',
|
||||
tax: order.totaltaxamount ?? 0,
|
||||
gstno: order.gstno ?? "",
|
||||
fee: order.deliverycharge ?? 0,
|
||||
items: order.orderdetails
|
||||
?.map((item) => {
|
||||
'name': item.productname ?? 'Unknown',
|
||||
'quantity': item.orderqty ?? 0,
|
||||
'productSumPrice': item.productsumprice ?? 0.0,
|
||||
'price': item.price ?? 0.0,
|
||||
'discountamount': item.price ?? 0.0,
|
||||
'image': item.productimage ?? '',
|
||||
})
|
||||
.toList() ??
|
||||
[],
|
||||
),
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0.05, 0),
|
||||
end: Offset.zero,
|
||||
).animate(animation),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 300),
|
||||
),
|
||||
);
|
||||
},
|
||||
transitionDuration:
|
||||
const Duration(
|
||||
milliseconds:
|
||||
300),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'View Details',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: primaryColor,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text(
|
||||
"View Details",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
886
lib/view/product/product_details.dart
Normal file
886
lib/view/product/product_details.dart
Normal file
@@ -0,0 +1,886 @@
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:nearledaily/view/product/products_list.dart';
|
||||
|
||||
// ─── Entry point ───────────────────────────────────────────────────────────────
|
||||
|
||||
void showProductSheet(BuildContext context, ProductItem item) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
barrierColor: Colors.black.withOpacity(0.4),
|
||||
builder: (_) => _ProductSheet(item: item),
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Sheet widget ──────────────────────────────────────────────────────────────
|
||||
|
||||
class _ProductSheet extends StatefulWidget {
|
||||
final ProductItem item;
|
||||
const _ProductSheet({required this.item});
|
||||
|
||||
@override
|
||||
State<_ProductSheet> createState() => _ProductSheetState();
|
||||
}
|
||||
|
||||
class _ProductSheetState extends State<_ProductSheet> {
|
||||
final DraggableScrollableController _drag = DraggableScrollableController();
|
||||
|
||||
static const double _minSize = 0.54;
|
||||
static const double _maxSize = 1.0;
|
||||
|
||||
int _qty = 1;
|
||||
bool _isFav = false;
|
||||
bool _inCart = false;
|
||||
double _expansion = 0.0;
|
||||
|
||||
static const Color _purple = Color(0xFF662582);
|
||||
static const Color _purpleLight = Color(0xFFF0EBFF);
|
||||
static const Color _dark = Color(0xFF111111);
|
||||
static const Color _surface = Color(0xFFF8F8F8);
|
||||
static const Color _muted = Color(0xFF888888);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_drag.addListener(_onDrag);
|
||||
}
|
||||
|
||||
void _onDrag() {
|
||||
if (!_drag.isAttached) return;
|
||||
final t = ((_drag.size - _minSize) / (_maxSize - _minSize)).clamp(0.0, 1.0);
|
||||
if (t > 0.88) {
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
|
||||
} else {
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
|
||||
}
|
||||
setState(() => _expansion = t);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
|
||||
_drag.removeListener(_onDrag);
|
||||
_drag.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
int get _discount {
|
||||
final orig = double.tryParse(
|
||||
widget.item.originalPrice.replaceAll(RegExp(r'[^\d.]'), '')) ?? 0;
|
||||
final cur = double.tryParse(
|
||||
widget.item.price.replaceAll(RegExp(r'[^\d.]'), '')) ?? 0;
|
||||
return orig > 0 ? ((orig - cur) / orig * 100).round() : 0;
|
||||
}
|
||||
|
||||
String get _savedAmount {
|
||||
final orig = double.tryParse(
|
||||
widget.item.originalPrice.replaceAll(RegExp(r'[^\d.]'), '')) ?? 0;
|
||||
final cur = double.tryParse(
|
||||
widget.item.price.replaceAll(RegExp(r'[^\d.]'), '')) ?? 0;
|
||||
final saved = orig - cur;
|
||||
return saved > 0 ? '₹${saved.toStringAsFixed(0)}' : '';
|
||||
}
|
||||
|
||||
void _snapToFull() => _drag.animateTo(_maxSize,
|
||||
duration: const Duration(milliseconds: 400), curve: Curves.easeOutCubic);
|
||||
|
||||
void _snapToPeek() => _drag.animateTo(_minSize,
|
||||
duration: const Duration(milliseconds: 300), curve: Curves.easeOutCubic);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final topPad = MediaQuery.of(context).padding.top;
|
||||
final botPad = MediaQuery.of(context).padding.bottom;
|
||||
final e = _expansion;
|
||||
final cornerRadius = lerpDouble(24.0, 0.0, e)!;
|
||||
final imageHeight = lerpDouble(300.0, topPad + 340.0, e)!;
|
||||
final discount = _discount;
|
||||
final saved = _savedAmount;
|
||||
|
||||
return DraggableScrollableSheet(
|
||||
controller: _drag,
|
||||
initialChildSize: _minSize,
|
||||
minChildSize: _minSize,
|
||||
maxChildSize: _maxSize,
|
||||
snap: true,
|
||||
snapSizes: const [_minSize, _maxSize],
|
||||
builder: (context, scrollCtrl) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.vertical(top: Radius.circular(cornerRadius)),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollCtrl,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ── Hero ──
|
||||
_buildHero(imageHeight, cornerRadius, topPad, e),
|
||||
|
||||
// ── Drag handle (peek) ──
|
||||
if (e < 0.2)
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFDDD8F0),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ── Body ──
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Tag chip
|
||||
_tagChip(widget.item.tag),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// Product name
|
||||
Text(
|
||||
widget.item.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _dark,
|
||||
letterSpacing: -0.4,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
|
||||
// Category / store
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFF4CAF50),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
widget.item.category,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: _muted,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
|
||||
// Price
|
||||
_buildPriceRow(discount, saved),
|
||||
const SizedBox(height: 6),
|
||||
if (saved.isNotEmpty)
|
||||
Text(
|
||||
'You save $saved · Free delivery on this order',
|
||||
style: const TextStyle(fontSize: 12, color: _muted),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
|
||||
// Rating
|
||||
_buildRatingRow(),
|
||||
|
||||
// Swipe hint
|
||||
if (e < 0.12) ...[
|
||||
const SizedBox(height: 20),
|
||||
_swipeHint(),
|
||||
],
|
||||
|
||||
// Expanded content
|
||||
if (e > 0.12) ...[
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Highlights
|
||||
AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
opacity: e > 0.4 ? 1.0 : 0.0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_sectionLabel('Why you\'ll love it'),
|
||||
const SizedBox(height: 10),
|
||||
_buildHighlights(),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// About (derived from name + category)
|
||||
AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 350),
|
||||
opacity: e > 0.52 ? 1.0 : 0.0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_sectionLabel('About'),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'A premium quality ${widget.item.name} carefully '
|
||||
'curated for you. Sourced from trusted partners at '
|
||||
'${widget.item.category}. Every order is freshness-'
|
||||
'guaranteed with no compromise on quality.',
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
color: Color(0xFF555555),
|
||||
height: 1.8,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Reviews
|
||||
AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
opacity: e > 0.62 ? 1.0 : 0.0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDivider(),
|
||||
const SizedBox(height: 20),
|
||||
_buildReviewsHeader(),
|
||||
const SizedBox(height: 12),
|
||||
_buildReviewCard(
|
||||
initials: 'PR',
|
||||
name: 'Priya R.',
|
||||
date: '2 days ago',
|
||||
stars: 5,
|
||||
text:
|
||||
'Absolutely love it! Super fresh and delivered on time. Will definitely order again.',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildReviewCard(
|
||||
initials: 'AK',
|
||||
name: 'Arjun K.',
|
||||
date: '1 week ago',
|
||||
stars: 5,
|
||||
text:
|
||||
'Great quality and packaging. Exactly as described. Fast delivery too!',
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Quantity
|
||||
AnimatedOpacity(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
opacity: e > 0.70 ? 1.0 : 0.0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDivider(),
|
||||
const SizedBox(height: 20),
|
||||
_buildQuantityRow(),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: botPad + 90),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ── CTA bar ──
|
||||
_buildCtaBar(botPad),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ── Hero ────────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildHero(
|
||||
double imageHeight, double cornerRadius, double topPad, double e) {
|
||||
final item = widget.item;
|
||||
final discount = _discount;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
// Product image
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(cornerRadius),
|
||||
topRight: Radius.circular(cornerRadius),
|
||||
),
|
||||
child: Container(
|
||||
height: imageHeight,
|
||||
width: double.infinity,
|
||||
color: item.bgColor,
|
||||
child: item.imageUrl.isNotEmpty
|
||||
? CachedNetworkImage(
|
||||
imageUrl: item.imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (_, __) => const Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2, color: _purple),
|
||||
),
|
||||
errorWidget: (_, __, ___) => Image.network(
|
||||
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQfoIZCZOkJq4Yg00gVdyXr49xxOJsFjSjABE_SAzOiDQ&s=10',
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
),
|
||||
|
||||
// Back / close button (full screen)
|
||||
// Positioned(
|
||||
// top: lerpDouble(-60, topPad + 12, e)!,
|
||||
// left: 14,
|
||||
// child: AnimatedOpacity(
|
||||
// opacity: e > 0.7 ? 1.0 : 0.0,
|
||||
// duration: const Duration(milliseconds: 150),
|
||||
// child: _circleButton(
|
||||
// icon: Icons.arrow_back_ios_new_rounded,
|
||||
// onTap: () {
|
||||
// HapticFeedback.lightImpact();
|
||||
// if (_drag.isAttached && _drag.size > _minSize + 0.05) {
|
||||
// _snapToPeek();
|
||||
// } else {
|
||||
// Navigator.pop(context);
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// Share + search (full screen)
|
||||
|
||||
|
||||
// Discount badge
|
||||
if (discount > 0)
|
||||
Positioned(
|
||||
bottom: 48,
|
||||
left: 16,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: _dark,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'$discount% OFF',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ── Tag chip ────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _tagChip(String label) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: _purpleLight,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _purple,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Price ───────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildPriceRow(int discount, String saved) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
widget.item.price,
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _dark,
|
||||
letterSpacing: -0.5,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
// Text(
|
||||
// widget.item.originalPrice,
|
||||
// style: const TextStyle(
|
||||
// fontSize: 14,
|
||||
// color: Color(0xFFBBBBBB),
|
||||
// decoration: TextDecoration.lineThrough,
|
||||
// decorationColor: Color(0xFFBBBBBB),
|
||||
// ),
|
||||
// ),
|
||||
if (discount > 0) ...[
|
||||
const SizedBox(width: 10),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: _dark,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
'$discount% OFF',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ── Rating ──────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildRatingRow() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(color: Color(0xFFF0F0F0)),
|
||||
bottom: BorderSide(color: Color(0xFFF0F0F0)),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Row(
|
||||
children: List.generate(
|
||||
5,
|
||||
(i) => Icon(
|
||||
i < widget.item.rating.floor()
|
||||
? Icons.star_rounded
|
||||
: Icons.star_border_rounded,
|
||||
size: 16,
|
||||
color: Colors.yellow.shade700,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
widget.item.rating.toStringAsFixed(1),
|
||||
style: const TextStyle(
|
||||
fontSize: 13, fontWeight: FontWeight.w700, color: _dark),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
// reviewCount is int — convert directly
|
||||
Text(
|
||||
'· ${widget.item.reviewCount} ratings',
|
||||
style: const TextStyle(fontSize: 12, color: _muted),
|
||||
),
|
||||
const Spacer(),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Highlights ──────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildHighlights() {
|
||||
final tiles = [
|
||||
_HighlightData(
|
||||
icon: Icons.bolt_rounded,
|
||||
label: 'Fast\nDelivery',
|
||||
sub: '20–45 min',
|
||||
iconColor: _purple,
|
||||
),
|
||||
_HighlightData(
|
||||
icon: Icons.verified_rounded,
|
||||
label: 'Quality\nVerified',
|
||||
sub: 'Trusted partners',
|
||||
iconColor: const Color(0xFF1B5E20),
|
||||
),
|
||||
_HighlightData(
|
||||
icon: Icons.refresh_rounded,
|
||||
label: 'Easy\nReturns',
|
||||
sub: 'Hassle-free',
|
||||
iconColor: const Color(0xFFB45309),
|
||||
),
|
||||
_HighlightData(
|
||||
icon: Icons.lock_outline_rounded,
|
||||
label: 'Secure\nPay',
|
||||
sub: '100% safe',
|
||||
iconColor: const Color(0xFF1565C0),
|
||||
),
|
||||
];
|
||||
|
||||
return Row(
|
||||
children: List.generate(tiles.length, (index) {
|
||||
final t = tiles[index];
|
||||
return Expanded(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(right: index < tiles.length - 1 ? 8 : 0),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: _surface,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(t.icon, color: t.iconColor, size: 20),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
t.label,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: t.iconColor,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
t.sub,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 9, color: _muted, height: 1.3),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Reviews ─────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildReviewsHeader() {
|
||||
return Row(
|
||||
children: [
|
||||
const Text(
|
||||
'Customer reviews',
|
||||
style: TextStyle(
|
||||
fontSize: 13, fontWeight: FontWeight.w700, color: _dark),
|
||||
),
|
||||
const Spacer(),
|
||||
// reviewCount is int
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildReviewCard({
|
||||
required String initials,
|
||||
required String name,
|
||||
required String date,
|
||||
required int stars,
|
||||
required String text,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: _surface,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 15,
|
||||
backgroundColor: _purpleLight,
|
||||
child: Text(
|
||||
initials,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _purple),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(name,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _dark)),
|
||||
Row(
|
||||
children: List.generate(
|
||||
stars,
|
||||
(_) => const Icon(Icons.star_rounded,
|
||||
size: 11, color: _dark),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Text(date,
|
||||
style: const TextStyle(fontSize: 11, color: _muted)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 12, color: Color(0xFF666666), height: 1.6),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Quantity ─────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildQuantityRow() {
|
||||
return Row(
|
||||
children: [
|
||||
_sectionLabel('Quantity'),
|
||||
const SizedBox(width: 16),
|
||||
_qtyButton(
|
||||
icon: Icons.remove_rounded,
|
||||
onTap: () {
|
||||
if (_qty > 1) {
|
||||
HapticFeedback.lightImpact();
|
||||
setState(() => _qty--);
|
||||
}
|
||||
},
|
||||
filled: false,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 180),
|
||||
transitionBuilder: (child, anim) =>
|
||||
ScaleTransition(scale: anim, child: child),
|
||||
child: Text(
|
||||
'$_qty',
|
||||
key: ValueKey(_qty),
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.w700, color: _dark),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_qtyButton(
|
||||
icon: Icons.add_rounded,
|
||||
onTap: () {
|
||||
HapticFeedback.lightImpact();
|
||||
setState(() => _qty++);
|
||||
},
|
||||
filled: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ── CTA bar ──────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildCtaBar(double botPad) {
|
||||
return Container(
|
||||
padding: EdgeInsets.fromLTRB(20, 14, 20, botPad + 16),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border(top: BorderSide(color: Color(0xFFF0F0F0))),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Wishlist
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
HapticFeedback.lightImpact();
|
||||
setState(() => _isFav = !_isFav);
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
width: 52,
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
color: _isFav ? const Color(0xFFFFF5F5) : Colors.white,
|
||||
border: Border.all(
|
||||
color: _isFav
|
||||
? const Color(0xFFFFD0D0)
|
||||
: const Color(0xFFE8E8E8),
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Icon(
|
||||
_isFav
|
||||
? Icons.favorite_rounded
|
||||
: Icons.favorite_border_rounded,
|
||||
color: _isFav ? const Color(0xFFE24B4A) : _dark,
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
|
||||
// Add to bag
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
HapticFeedback.mediumImpact();
|
||||
setState(() => _inCart = true);
|
||||
_snapToFull();
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
height: 52,
|
||||
decoration: BoxDecoration(
|
||||
color: _inCart ? const Color(0xFF2E2E2E) : _dark,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
_inCart ? 'Added ✓' : 'Add to cart',
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
letterSpacing: -0.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Swipe hint ───────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _swipeHint() {
|
||||
return GestureDetector(
|
||||
onTap: _snapToFull,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: _purple.withOpacity(0.2)),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'Swipe up for full details',
|
||||
style: TextStyle(
|
||||
fontSize: 13, fontWeight: FontWeight.w600, color: _purple),
|
||||
),
|
||||
SizedBox(width: 6),
|
||||
Icon(Icons.keyboard_arrow_up_rounded, color: _purple, size: 18),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
Widget _buildDivider() =>
|
||||
Container(height: 1, color: const Color(0xFFF0F0F0));
|
||||
|
||||
Widget _sectionLabel(String label) => Text(
|
||||
label.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _muted,
|
||||
letterSpacing: 1.0,
|
||||
),
|
||||
);
|
||||
|
||||
Widget _circleButton({required IconData icon, required VoidCallback onTap}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.85),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, size: 18, color: _dark),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _qtyButton(
|
||||
{required IconData icon,
|
||||
required VoidCallback onTap,
|
||||
required bool filled}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: filled ? _dark : Colors.white,
|
||||
border:
|
||||
Border.all(color: filled ? _dark : const Color(0xFFE8E8E8)),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(icon, size: 18, color: filled ? Colors.white : _dark),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Internal data class ────────────────────────────────────────────────────────
|
||||
|
||||
class _HighlightData {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String sub;
|
||||
final Color iconColor;
|
||||
const _HighlightData({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.sub,
|
||||
required this.iconColor,
|
||||
});
|
||||
}
|
||||
@@ -3,14 +3,11 @@ import 'package:flutter/services.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
import 'package:readmore/readmore.dart';
|
||||
import '../../constants/color_constants.dart';
|
||||
import '../../constants/font_constants.dart';
|
||||
import '../../controllers/cart_controller/cart.dart';
|
||||
import '../../controllers/product/variant_controller.dart';
|
||||
import '../../domain/provider/varient/varient_pro.dart';
|
||||
import '../../modules/product/product.dart';
|
||||
import '../../widgets/text_widget.dart';
|
||||
|
||||
class ProductViewPage extends StatefulWidget {
|
||||
final Product product;
|
||||
|
||||
878
lib/view/product/products_list.dart
Normal file
878
lib/view/product/products_list.dart
Normal file
@@ -0,0 +1,878 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:nearledaily/view/product/product_details.dart';
|
||||
import 'package:nearledaily/view/product/refill_home_screen.dart';
|
||||
import 'package:wheel_chooser/wheel_chooser.dart';
|
||||
|
||||
import '../../widgets/fav_button.dart';
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// MODEL
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
class ProductItem {
|
||||
final String name;
|
||||
final String category;
|
||||
final String price;
|
||||
final String originalPrice;
|
||||
final String imageUrl;
|
||||
final Color bgColor;
|
||||
final double rating;
|
||||
final int reviewCount;
|
||||
final String tag;
|
||||
|
||||
ProductItem({
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.price,
|
||||
required this.originalPrice,
|
||||
required this.imageUrl,
|
||||
required this.bgColor,
|
||||
required this.rating,
|
||||
required this.reviewCount,
|
||||
required this.tag,
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// SAMPLE DATA
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
final allProducts = [
|
||||
ProductItem(
|
||||
name: 'Margherita Pizza',
|
||||
category: 'Dominos · 20 min',
|
||||
price: '₹149',
|
||||
originalPrice: '₹199',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1513104890138-7c749659a591?w=500',
|
||||
bgColor: const Color(0xFFFFF3E0),
|
||||
rating: 4.6,
|
||||
reviewCount: 512,
|
||||
tag: 'Food',
|
||||
),
|
||||
|
||||
ProductItem(
|
||||
name: 'Fresh Veggie Basket',
|
||||
category: 'BigBasket · 45 min',
|
||||
price: '₹299',
|
||||
originalPrice: '₹420',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1542838132-92c53300491e?w=500',
|
||||
bgColor: const Color(0xFFE8F5E9),
|
||||
rating: 4.5,
|
||||
reviewCount: 180,
|
||||
tag: 'Grocery',
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Margherita Pizza',
|
||||
category: 'Dominos · 20 min',
|
||||
price: '₹149',
|
||||
originalPrice: '₹199',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1513104890138-7c749659a591?w=500',
|
||||
bgColor: const Color(0xFFFFF3E0),
|
||||
rating: 4.6,
|
||||
reviewCount: 512,
|
||||
tag: 'Food',
|
||||
),
|
||||
|
||||
ProductItem(
|
||||
name: 'Chicken Biryani',
|
||||
category: 'HotPot · 30 min',
|
||||
price: '₹189',
|
||||
originalPrice: '₹240',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1631515243349-e0cb75fb8d3a?w=500',
|
||||
bgColor: const Color(0xFFFBE9E7),
|
||||
rating: 4.8,
|
||||
reviewCount: 320,
|
||||
tag: 'Food',
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Margherita Pizza',
|
||||
category: 'Dominos · 20 min',
|
||||
price: '₹149',
|
||||
originalPrice: '₹199',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1513104890138-7c749659a591?w=500',
|
||||
bgColor: const Color(0xFFFFF3E0),
|
||||
rating: 4.6,
|
||||
reviewCount: 512,
|
||||
tag: 'Food',
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Birthday Cake',
|
||||
category: 'CakeZone · 60 min',
|
||||
price: '₹549',
|
||||
originalPrice: '₹699',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1578985545062-69928b1d9587?w=500',
|
||||
bgColor: const Color(0xFFFCE4EC),
|
||||
rating: 4.9,
|
||||
reviewCount: 94,
|
||||
tag: 'Bakery',
|
||||
),
|
||||
ProductItem(
|
||||
name: 'Margherita Pizza',
|
||||
category: 'Dominos · 20 min',
|
||||
price: '₹149',
|
||||
originalPrice: '₹199',
|
||||
imageUrl:
|
||||
'https://images.unsplash.com/photo-1513104890138-7c749659a591?w=500',
|
||||
bgColor: const Color(0xFFFFF3E0),
|
||||
rating: 4.6,
|
||||
reviewCount: 512,
|
||||
tag: 'Food',
|
||||
),
|
||||
];
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// FILTER CHIPS DATA
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
const filterTabs = ['All', 'Food', 'Grocery', 'Bakery', 'Drinks'];
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// PRODUCTS PAGE
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
class ProductsList extends StatefulWidget {
|
||||
const ProductsList({super.key});
|
||||
|
||||
@override
|
||||
State<ProductsList> createState() => _ProductsListState();
|
||||
}
|
||||
|
||||
class _ProductsListState extends State<ProductsList> {
|
||||
String _selectedFilter = 'All';
|
||||
String _sortBy = 'Popular';
|
||||
|
||||
List<ProductItem> get _filtered => _selectedFilter == 'All'
|
||||
? allProducts
|
||||
: allProducts.where((p) => p.tag == _selectedFilter).toList();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF7F7FA),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
|
||||
// ── App Bar ──
|
||||
SliverAppBar(
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
pinned: true,
|
||||
title: const Text(
|
||||
'Products',
|
||||
style: TextStyle(
|
||||
color: Color(0xFF1A1A1A),
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
centerTitle: false,
|
||||
leading: const BackButton(color: Color(0xFF1A1A1A)),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search_rounded,
|
||||
color: Color(0xFF1A1A1A)),
|
||||
onPressed: () {
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => const AutoRefillDemo()));
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.tune_rounded,
|
||||
color: Color(0xFF1A1A1A)),
|
||||
onPressed: () => _showSortSheet(context),
|
||||
),
|
||||
],
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(1),
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: const Color(0xFFEEEEEE),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ── Filter chips ──
|
||||
SliverPersistentHeader(
|
||||
pinned: true,
|
||||
delegate: _FilterHeaderDelegate(
|
||||
selectedFilter: _selectedFilter,
|
||||
sortBy: _sortBy,
|
||||
onFilterChanged: (f) => setState(() => _selectedFilter = f),
|
||||
onSortTap: () => _showSortSheet(context),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
// ── Product grid ──
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
childAspectRatio: 0.72,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => _ProductCard(item: _filtered[index]),
|
||||
childCount: _filtered.length,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showSortSheet(BuildContext context) {
|
||||
final options = ['Popular', 'Price: Low to High', 'Price: High to Low', 'Rating', 'Discount'];
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
backgroundColor: Colors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
builder: (_) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 16, 20, 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE0E0E0),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Sort by',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
...options.map((opt) => InkWell(
|
||||
onTap: () {
|
||||
setState(() => _sortBy = opt);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
opt,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: _sortBy == opt
|
||||
? FontWeight.w700
|
||||
: FontWeight.w400,
|
||||
color: _sortBy == opt
|
||||
? const Color(0xFF7C3AED)
|
||||
: const Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_sortBy == opt)
|
||||
const Icon(Icons.check_circle_rounded,
|
||||
color: Color(0xFF7C3AED), size: 20),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// STICKY FILTER HEADER DELEGATE
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
class _FilterHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||
final String selectedFilter;
|
||||
final String sortBy;
|
||||
final ValueChanged<String> onFilterChanged;
|
||||
final VoidCallback onSortTap;
|
||||
|
||||
_FilterHeaderDelegate({
|
||||
required this.selectedFilter,
|
||||
required this.sortBy,
|
||||
required this.onFilterChanged,
|
||||
required this.onSortTap,
|
||||
});
|
||||
|
||||
@override
|
||||
double get minExtent => 56;
|
||||
@override
|
||||
double get maxExtent => 56;
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: filterTabs.length + 1, // +1 for sort chip
|
||||
separatorBuilder: (_, __) => const SizedBox(width: 8),
|
||||
itemBuilder: (context, index) {
|
||||
// Last item = Sort chip
|
||||
if (index == filterTabs.length) {
|
||||
return GestureDetector(
|
||||
onTap: onSortTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF3F0FF),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFD4C5FF), width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.swap_vert_rounded,
|
||||
size: 15, color: Color(0xFF662582)),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
sortBy == 'Popular' ? 'Sort' : sortBy,
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF662582),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final tab = filterTabs[index];
|
||||
final isSelected = selectedFilter == tab;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onFilterChanged(tab),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? const Color(0xFF662582)
|
||||
: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? const Color(0xFF662582)
|
||||
: const Color(0xFFE0E0E0),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
tab,
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: const Color(0xFF757575),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Container(height: 1, color: const Color(0xFFEEEEEE)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRebuild(_FilterHeaderDelegate old) =>
|
||||
old.selectedFilter != selectedFilter || old.sortBy != sortBy;
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// PRODUCT CARD
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
class _ProductCard extends StatefulWidget {
|
||||
final ProductItem item;
|
||||
const _ProductCard({required this.item});
|
||||
|
||||
@override
|
||||
State<_ProductCard> createState() => _ProductCardState();
|
||||
}
|
||||
|
||||
class _ProductCardState extends State<_ProductCard> {
|
||||
bool _isFav = false;
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final item = widget.item;
|
||||
int selectedIndex = 2;
|
||||
|
||||
final original = double.tryParse(
|
||||
item.originalPrice.replaceAll(RegExp(r'[^\d.]'), '')) ??
|
||||
0;
|
||||
final current =
|
||||
double.tryParse(item.price.replaceAll(RegExp(r'[^\d.]'), '')) ?? 0;
|
||||
final discount =
|
||||
original > 0 ? ((original - current) / original * 100).round() : 0;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
// ── Image area ──
|
||||
Stack(
|
||||
children: [
|
||||
|
||||
// Image or emoji fallback
|
||||
GestureDetector(
|
||||
onTap: () => showProductSheet(context, item),
|
||||
|
||||
child: SizedBox(
|
||||
height: 140,
|
||||
width: double.infinity,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: item.imageUrl,
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
errorWidget: (context, url, error) => _fallback(item),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Discount badge — top left
|
||||
if (discount > 0)
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 10,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF662582),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
'$discount% OFF',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Favourite — top right
|
||||
Positioned(
|
||||
top: 8,
|
||||
right: 8,
|
||||
child: FavButton(
|
||||
size: 32,
|
||||
initialValue: _isFav,
|
||||
onChanged: (val) => setState(() => _isFav = val),
|
||||
),
|
||||
),
|
||||
|
||||
// Add button — bottom right ON image
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: 10,
|
||||
child: GestureDetector(
|
||||
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
|
||||
context: context,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
builder: (context) {
|
||||
return StatefulBuilder(
|
||||
builder: (context, setModalState) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
height: 420,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 50,
|
||||
height: 5,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade300,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
const Text(
|
||||
"Choose Variant",
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xFF662582),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 3),
|
||||
|
||||
Text(
|
||||
"Scroll to select your size",
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade600,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
Expanded(
|
||||
child: PageView.builder(
|
||||
controller: PageController(
|
||||
viewportFraction: 0.30,
|
||||
initialPage: selectedIndex,
|
||||
),
|
||||
onPageChanged: (index) {
|
||||
setModalState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
},
|
||||
itemCount: 5,
|
||||
itemBuilder: (context, index) {
|
||||
final items = [
|
||||
{
|
||||
"name": "Small",
|
||||
"price": "₹149",
|
||||
"image":
|
||||
"https://images.unsplash.com/photo-1513104890138-7c749659a591?w=500",
|
||||
},
|
||||
{
|
||||
"name": "Medium",
|
||||
"price": "₹199",
|
||||
"image":
|
||||
"https://images.unsplash.com/photo-1565299624946-b28f40a0ae38?w=500",
|
||||
},
|
||||
{
|
||||
"name": "Large",
|
||||
"price": "₹249",
|
||||
"image":
|
||||
"https://images.unsplash.com/photo-1514326640560-7d063ef2aed5?w=500",
|
||||
},
|
||||
{
|
||||
"name": "XL",
|
||||
"price": "₹299",
|
||||
"image":
|
||||
"https://images.unsplash.com/photo-1594007654729-407eedc4be65?w=500",
|
||||
},
|
||||
{
|
||||
"name": "Party",
|
||||
"price": "₹399",
|
||||
"image":
|
||||
"https://images.unsplash.com/photo-1514326640560-7d063ef2aed5?w=500",
|
||||
},
|
||||
];
|
||||
|
||||
final isSelected = selectedIndex == index;
|
||||
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeOut,
|
||||
transform: Matrix4.identity()
|
||||
..scale(isSelected ? 1.15 : 1.15),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
width: isSelected ? 100 : 85,
|
||||
height: isSelected ? 100 : 85,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? const Color(0xFF662582)
|
||||
: Colors.transparent,
|
||||
width: 3,
|
||||
),
|
||||
|
||||
),
|
||||
child: ClipOval(
|
||||
child: Image.network(
|
||||
items[index]["image"]!,
|
||||
fit: BoxFit.fill,
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 15),
|
||||
|
||||
AnimatedDefaultTextStyle(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
style: TextStyle(
|
||||
fontSize: isSelected ? 18 : 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: isSelected
|
||||
? Colors.black
|
||||
: Colors.grey.shade600,
|
||||
),
|
||||
child: Text(items[index]["name"]!),
|
||||
),
|
||||
|
||||
const SizedBox(height: 5),
|
||||
|
||||
AnimatedDefaultTextStyle(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF662582),
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: isSelected ? 16 : 12,
|
||||
),
|
||||
child: Text(items[index]["price"]!),
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 56,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF662582),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
),
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"Confirm Selection",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 34,
|
||||
height: 34,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.12),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add_rounded,
|
||||
color: Color(0xFF662582),
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// ── Info area ──
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 10, 12, 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
// Category
|
||||
Text(
|
||||
item.category,
|
||||
style: const TextStyle(
|
||||
fontSize: 10.5,
|
||||
color: Color(0xFF662582),
|
||||
fontWeight: FontWeight.w600,
|
||||
letterSpacing: 0.2,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
const SizedBox(height: 3),
|
||||
|
||||
// Name
|
||||
Text(
|
||||
item.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF1A1A1A),
|
||||
height: 1.2,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
const SizedBox(height: 6),
|
||||
|
||||
// Rating
|
||||
Row(
|
||||
children: [
|
||||
const Icon(Icons.star_rounded,
|
||||
size: 13, color: Color(0xFFFFC107)),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
'${item.rating}',
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
'(${item.reviewCount})',
|
||||
style: const TextStyle(
|
||||
fontSize: 10.5,
|
||||
color: Color(0xFF9E9E9E),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 8),
|
||||
|
||||
// Price
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
item.price,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: Color(0xFF1A1A1A),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
if (discount > 0)
|
||||
Text(
|
||||
item.originalPrice,
|
||||
style: const TextStyle(
|
||||
fontSize: 11,
|
||||
color: Color(0xFF9E9E9E),
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _fallback(ProductItem item) {
|
||||
return Container(
|
||||
height: 140,
|
||||
width: double.infinity,
|
||||
color: item.bgColor,
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 40,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
1228
lib/view/product/refill_home_screen.dart
Normal file
1228
lib/view/product/refill_home_screen.dart
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ import 'package:lottie/lottie.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
|
||||
import '../../controllers/tenant/create_tenant.dart';
|
||||
import '../../controllers/tenant_controller /tenant_list.dart';
|
||||
import '../../controllers/tenant_list/tenant_controller.dart';
|
||||
import '../home_view.dart';
|
||||
|
||||
class QrScannerPage extends StatefulWidget {
|
||||
|
||||
Reference in New Issue
Block a user