proxibuy/lib/data/models/datasources/offer_data_source.dart

241 lines
7.4 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}