proxybuy-flutter/lib/screens/product/shop.dart

288 lines
9.2 KiB
Dart

// ignore_for_file: unused_local_variable, deprecated_member_use
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:lba/data/model/workingHours.dart';
import 'package:lba/gen/assets.gen.dart';
import 'package:lba/res/colors.dart';
import 'package:lba/widgets/customCard.dart';
import 'package:lba/widgets/dividerTitle.dart';
import 'package:lba/widgets/openChecker.dart';
import 'package:lba/widgets/rate.dart';
import 'package:maps_launcher/maps_launcher.dart';
class Shop extends StatefulWidget {
final String shopName;
final double star;
final String place;
final List<String> branches;
final List<WorkingHours> workingHours;
final String facilities;
const Shop({
super.key,
required this.shopName,
required this.star,
required this.place,
required this.branches,
required this.workingHours,
required this.facilities,
});
@override
State<Shop> createState() => _ShopState();
}
class _ShopState extends State<Shop> {
late String selectedPlace;
bool isActiveOffer = true;
@override
void initState() {
super.initState();
selectedPlace = widget.place;
}
@override
Widget build(BuildContext context) {
final now = DateTime.now();
final schedule = IsOpenChecker.getTodaySchedule(widget.workingHours);
final isOpen = IsOpenChecker.isOpenNow(widget.workingHours);
String timeRange = '';
if (isOpen && schedule.shifts.isNotEmpty) {
for (final shift in schedule.shifts) {
timeRange +=
'${formatTime12Hour(shift.openAt)} - ${formatTime12Hour(shift.closeAt)} ';
}
}
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
SvgPicture.asset(
Assets.icons.shop.path,
color: Colors.black,
height: 25,
),
SizedBox(width: 10),
Text(
widget.shopName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17),
),
],
),
SizedBox(height: 15),
Row(
children: [
CustomStarRating(rating: widget.star),
SizedBox(width: 5),
Text(
widget.star.toString(),
style: TextStyle(color: LightAppColors.productDetailDivider),
),
],
),
SizedBox(height: 5),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
SvgPicture.asset(
Assets.icons.location.path,
color: Colors.black,
),
SizedBox(width: 5),
Text(
selectedPlace,
style: TextStyle(
color: LightAppColors.productDetailDivider,
),
),
],
),
PopupMenuButton<String>(
color: Colors.white,
icon: SvgPicture.asset(
Assets.icons.arrowDown.path,
color: Colors.black,
height: 20,
),
onSelected: (String newPlace) {
setState(() {
selectedPlace = newPlace;
});
},
itemBuilder: (BuildContext context) {
return widget.branches.map((String branch) {
return PopupMenuItem<String>(
value: branch,
child: Text(branch),
);
}).toList();
},
),
],
),
SizedBox(height: 5),
Row(
children: [
SvgPicture.asset(Assets.icons.clock.path),
SizedBox(width: 5),
Text(
isOpen ? 'Open Now' : 'Closed',
style: TextStyle(color: isOpen ? Colors.green : Colors.red),
),
SizedBox(width: 5),
Container(
color: LightAppColors.productDetailDivider,
width: 1,
height: 13,
),
SizedBox(width: 5),
Text(
timeRange,
style: TextStyle(color: LightAppColors.productDetailDivider),
),
],
),
SizedBox(height: 15),
DividerTitleWidget(title: "Facilities"),
SizedBox(
height: 50,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: 1,
itemBuilder: (context, index) {
return Row(
children: [
SvgPicture.asset(Assets.icons.tick.path),
SizedBox(width: 5),
Text(
widget.facilities,
style: TextStyle(
color: LightAppColors.productDetailDivider,
),
),
],
);
},
),
),
SizedBox(height: 20),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: LightAppColors.confirmButton,
minimumSize: const Size(double.infinity, 48),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
),
onPressed: () {
MapsLauncher.launchCoordinates(25.2399, 55.2744);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.icons.routing2.path,
color: Colors.black,
),
SizedBox(width: 5),
Text(
"Direction",
style: const TextStyle(
color: Colors.black,
fontSize: 16,
),
),
],
),
),
SizedBox(height: 30),
Text(
"List of offers",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
SizedBox(height: 15),
Container(
height: 45,
width: 150,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: const Color.fromARGB(17, 77, 77, 77),
),
child: Row(
children: [
GestureDetector(
onTap: () {
setState(() {
isActiveOffer = true;
});
},
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
height: 35,
width: 70,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: isActiveOffer ? Colors.white : Colors.transparent,
),
child: Center(child: Text("Active")),
),
),
),
GestureDetector(
onTap: () {
setState(() {
isActiveOffer = false;
});
},
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Container(
height: 35,
width: 60,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: !isActiveOffer ? Colors.white : Colors.transparent,
),
child: Center(child: Text("Old")),
),
),
),
],
),
),
SizedBox(height: 15),
SizedBox(
height: 160,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: 2,
itemBuilder: (context, index) {
return CustomCard(
title: "Calamaro Table Lamp",
description: "Elegant lighting with a modern twist.",
);
},
),
),
],
),
),
);
}
}