241 lines
7.4 KiB
Dart
241 lines
7.4 KiB
Dart
import 'package:proxibuy/data/models/offer_model.dart';
|
||
import 'package:proxibuy/data/models/working_hours.dart';
|
||
|
||
abstract class OfferDataSource {
|
||
Future<List<OfferModel>> getNearbyOffers();
|
||
Future<OfferModel?> getOfferById(String id); // <<<<<<< جدید
|
||
}
|
||
|
||
class MockOfferDataSource implements OfferDataSource {
|
||
final List<OfferModel> _mockOffers = [
|
||
OfferModel(
|
||
id: '1',
|
||
storeName: 'روچیک (Ruchik)',
|
||
title: 'چیزبرگر',
|
||
discount: '۲۰٪',
|
||
imageUrls: [
|
||
'https://picsum.photos/seed/food/400/200',
|
||
'https://picsum.photos/seed/burger1/400/400',
|
||
'https://picsum.photos/seed/burger2/400/400',
|
||
],
|
||
category: 'فستفود',
|
||
distanceInMeters: 130,
|
||
expiryTime: DateTime.now().add(const Duration(hours: 2, minutes: 30, seconds: 10)),
|
||
rating: 4.8,
|
||
workingHours: [
|
||
WorkingHours(
|
||
day: 'شنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'یکشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'دوشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'سهشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'چهارشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'پنجشنبه',
|
||
shifts: [
|
||
Shift(openAt: '۱۰ صبح', closeAt: '۱ ظهر'),
|
||
Shift(openAt: '۵ عصر', closeAt: '۱۱ شب'),
|
||
],
|
||
),
|
||
WorkingHours(day: 'جمعه', shifts: []),
|
||
],
|
||
discountType: 'رفیقبازی',
|
||
isOpen: false,
|
||
address: 'چهارباغ پایین ',
|
||
ratingCount: 340,
|
||
latitude: 32.660,
|
||
longitude: 51.670,
|
||
originalPrice: 150000,
|
||
finalPrice: 120000,
|
||
),
|
||
OfferModel(
|
||
id: '2',
|
||
storeName: 'کاخ سرهنگ',
|
||
title: 'عصرانه',
|
||
discount: '۲۰% ',
|
||
imageUrls: [
|
||
'https://picsum.photos/seed/food/400/200',
|
||
'https://picsum.photos/seed/burger1/400/400',
|
||
'https://picsum.photos/seed/burger2/400/400',
|
||
],
|
||
category: 'رستوران',
|
||
distanceInMeters: 130,
|
||
expiryTime: DateTime.now().add(const Duration(hours: 5)),
|
||
rating: 4.8,
|
||
workingHours: [
|
||
WorkingHours(
|
||
day: 'شنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'یکشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'دوشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'سهشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'چهارشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'پنجشنبه',
|
||
shifts: [
|
||
Shift(openAt: '۱۰ صبح', closeAt: '۱ ظهر'),
|
||
Shift(openAt: '۵ عصر', closeAt: '۱۱ شب'),
|
||
],
|
||
),
|
||
WorkingHours(day: 'جمعه', shifts: []), // تعطیل
|
||
],
|
||
discountType: 'رفیقبازی',
|
||
isOpen: true,
|
||
address: 'چهارباغ پایین ',
|
||
ratingCount: 340,
|
||
latitude: 32.660,
|
||
longitude: 51.670,
|
||
originalPrice: 150000,
|
||
finalPrice: 120000,
|
||
),
|
||
OfferModel(
|
||
id: '3',
|
||
storeName: 'روچیک (Ruchik)',
|
||
title: 'چیزبرگر',
|
||
discount: '۲۰٪',
|
||
imageUrls: [
|
||
'https://picsum.photos/seed/food/400/200',
|
||
'https://picsum.photos/seed/burger1/400/400',
|
||
'https://picsum.photos/seed/burger2/400/400',
|
||
],
|
||
category: 'فستفود',
|
||
distanceInMeters: 130,
|
||
expiryTime: DateTime.now().add(const Duration(hours: 5)),
|
||
rating: 4.8,
|
||
workingHours: [
|
||
WorkingHours(
|
||
day: 'شنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'یکشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'دوشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'سهشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'چهارشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'پنجشنبه',
|
||
shifts: [
|
||
Shift(openAt: '۱۰ صبح', closeAt: '۱ ظهر'),
|
||
Shift(openAt: '۵ عصر', closeAt: '۱۱ شب'),
|
||
],
|
||
),
|
||
WorkingHours(day: 'جمعه', shifts: []), // تعطیل
|
||
],
|
||
discountType: 'رفیقبازی',
|
||
isOpen: true,
|
||
address: 'چهارباغ پایین ',
|
||
ratingCount: 340,
|
||
latitude: 32.660,
|
||
longitude: 51.670,
|
||
originalPrice: 150000,
|
||
finalPrice: 120000,
|
||
),
|
||
OfferModel(
|
||
id: '4',
|
||
storeName: 'روچیک (Ruchik)',
|
||
title: 'چیزبرگر',
|
||
discount: '۲۰٪',
|
||
imageUrls: [
|
||
'https://picsum.photos/seed/food/400/200',
|
||
'https://picsum.photos/seed/burger1/400/400',
|
||
'https://picsum.photos/seed/burger2/400/400',
|
||
],
|
||
category: 'فستفود',
|
||
distanceInMeters: 130,
|
||
expiryTime: DateTime.now().add(const Duration(hours: 5)),
|
||
rating: 4.8,
|
||
workingHours: [
|
||
WorkingHours(
|
||
day: 'شنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'یکشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'دوشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'سهشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'چهارشنبه',
|
||
shifts: [Shift(openAt: '۱۰ صبح', closeAt: '۱۰ شب')],
|
||
),
|
||
WorkingHours(
|
||
day: 'پنجشنبه',
|
||
shifts: [
|
||
Shift(openAt: '۱۰ صبح', closeAt: '۱ ظهر'),
|
||
Shift(openAt: '۵ عصر', closeAt: '۱۱ شب'),
|
||
],
|
||
),
|
||
WorkingHours(day: 'جمعه', shifts: []),
|
||
],
|
||
discountType: 'رفیقبازی',
|
||
isOpen: false,
|
||
address: 'چهارباغ پایین ',
|
||
ratingCount: 340,
|
||
latitude: 32.660,
|
||
longitude: 51.670,
|
||
originalPrice: 150000,
|
||
finalPrice: 120000,
|
||
),
|
||
];
|
||
|
||
@override
|
||
Future<List<OfferModel>> getNearbyOffers() async {
|
||
await Future.delayed(const Duration(seconds: 1));
|
||
return _mockOffers;
|
||
}
|
||
|
||
@override
|
||
Future<OfferModel?> getOfferById(String id) async {
|
||
await Future.delayed(const Duration(milliseconds: 300));
|
||
try {
|
||
return _mockOffers.firstWhere((offer) => offer.id == id);
|
||
} catch (e) {
|
||
return null;
|
||
}
|
||
}
|
||
}
|