fix: some problems are fixed
This commit is contained in:
@@ -114,8 +114,8 @@ Future<void> setupLocator() async {
|
|||||||
locator.registerFactory<AuthBloc>(
|
locator.registerFactory<AuthBloc>(
|
||||||
() => AuthBloc(locator(), locator(), locator(), locator()));
|
() => AuthBloc(locator(), locator(), locator(), locator()));
|
||||||
locator.registerFactory<WalletBloc>(() => WalletBloc(locator(), locator()));
|
locator.registerFactory<WalletBloc>(() => WalletBloc(locator(), locator()));
|
||||||
locator.registerFactory<ShopBloc>(() => ShopBloc(
|
locator.registerFactory<ShopBloc>(() => ShopBloc(locator(), locator(),
|
||||||
locator(), locator(), locator(), locator(), locator(), locator()));
|
locator(), locator(), locator(), locator(), locator()));
|
||||||
locator.registerFactory<ProfileBloc>(
|
locator.registerFactory<ProfileBloc>(
|
||||||
() => ProfileBloc(locator(), locator()));
|
() => ProfileBloc(locator(), locator()));
|
||||||
locator.registerFactory<LeaderboardBloc>(() => LeaderboardBloc(locator()));
|
locator.registerFactory<LeaderboardBloc>(() => LeaderboardBloc(locator()));
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ class BazaarPaymentGateway implements PaymentGateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PurchaseResult> purchase(String productSku) async {
|
Future<PurchaseResult> purchase(String productSku, {String payload = ''}) async {
|
||||||
try {
|
try {
|
||||||
await connect();
|
await connect();
|
||||||
final info = await FlutterPoolakey.purchase(
|
final info = await FlutterPoolakey.purchase(
|
||||||
productSku,
|
productSku,
|
||||||
payload: 'hakemsho',
|
payload: payload.isNotEmpty ? payload : 'hakemsho',
|
||||||
);
|
);
|
||||||
if (info.purchaseToken.isEmpty) {
|
if (info.purchaseToken.isEmpty) {
|
||||||
return const PurchaseResult.failure();
|
return const PurchaseResult.failure();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class DevPaymentGateway implements PaymentGateway {
|
|||||||
Future<void> connect() async {}
|
Future<void> connect() async {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PurchaseResult> purchase(String productSku) async {
|
Future<PurchaseResult> purchase(String productSku, {String payload = ''}) async {
|
||||||
final stamp = DateTime.now().millisecondsSinceEpoch;
|
final stamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
return PurchaseResult.success(
|
return PurchaseResult.success(
|
||||||
token: 'dev-$productSku-$stamp',
|
token: 'dev-$productSku-$stamp',
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ class MyketPaymentGateway implements PaymentGateway {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<PurchaseResult> purchase(String productSku) async {
|
Future<PurchaseResult> purchase(String productSku, {String payload = ''}) async {
|
||||||
await connect();
|
await connect();
|
||||||
final Map<dynamic, dynamic> result =
|
final Map<dynamic, dynamic> result = await MyketIAP.launchPurchaseFlow(
|
||||||
await MyketIAP.launchPurchaseFlow(sku: productSku, payload: 'hakemsho');
|
sku: productSku,
|
||||||
|
payload: payload.isNotEmpty ? payload : 'hakemsho',
|
||||||
|
);
|
||||||
|
|
||||||
final Purchase? purchase = result[MyketIAP.PURCHASE] as Purchase?;
|
final Purchase? purchase = result[MyketIAP.PURCHASE] as Purchase?;
|
||||||
if (purchase == null || purchase.mToken.isEmpty) {
|
if (purchase == null || purchase.mToken.isEmpty) {
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ abstract class PaymentGateway {
|
|||||||
String get store;
|
String get store;
|
||||||
|
|
||||||
/// جریانِ خریدِ [productSku] (همان UUIDِ محصول در پنلِ فروشگاه) را باز میکند.
|
/// جریانِ خریدِ [productSku] (همان UUIDِ محصول در پنلِ فروشگاه) را باز میکند.
|
||||||
Future<PurchaseResult> purchase(String productSku);
|
/// [payload] در فروشگاه ذخیره و در پنلِ توسعهدهنده نمایش داده میشود؛ اینجا
|
||||||
|
/// شمارهی موبایلِ کاربر را میفرستیم تا خرید قابلِ ردیابی باشد.
|
||||||
|
Future<PurchaseResult> purchase(String productSku, {String payload = ''});
|
||||||
|
|
||||||
/// اتصالِ اولیه (در صورتِ نیاز). پیش از اولین خرید صدا زده میشود.
|
/// اتصالِ اولیه (در صورتِ نیاز). پیش از اولین خرید صدا زده میشود.
|
||||||
Future<void> connect() async {}
|
Future<void> connect() async {}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
|
||||||
/// ذخیرهی امن توکن JWT.
|
/// ذخیرهی امن توکن JWT و شمارهی موبایلِ کاربر.
|
||||||
class TokenStorage {
|
class TokenStorage {
|
||||||
static const _key = 'jwt_token';
|
static const _key = 'jwt_token';
|
||||||
|
static const _mobileKey = 'user_mobile';
|
||||||
final FlutterSecureStorage _storage;
|
final FlutterSecureStorage _storage;
|
||||||
|
|
||||||
TokenStorage([FlutterSecureStorage? storage])
|
TokenStorage([FlutterSecureStorage? storage])
|
||||||
@@ -12,5 +13,13 @@ class TokenStorage {
|
|||||||
|
|
||||||
Future<void> write(String token) => _storage.write(key: _key, value: token);
|
Future<void> write(String token) => _storage.write(key: _key, value: token);
|
||||||
|
|
||||||
Future<void> clear() => _storage.delete(key: _key);
|
Future<String?> readMobile() => _storage.read(key: _mobileKey);
|
||||||
|
|
||||||
|
Future<void> writeMobile(String mobile) =>
|
||||||
|
_storage.write(key: _mobileKey, value: mobile);
|
||||||
|
|
||||||
|
Future<void> clear() async {
|
||||||
|
await _storage.delete(key: _key);
|
||||||
|
await _storage.delete(key: _mobileKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class AuthLocalData {
|
|||||||
Future<String?> readToken() => _storage.read();
|
Future<String?> readToken() => _storage.read();
|
||||||
Future<void> clearToken() => _storage.clear();
|
Future<void> clearToken() => _storage.clear();
|
||||||
|
|
||||||
|
Future<void> saveMobile(String mobile) => _storage.writeMobile(mobile);
|
||||||
|
Future<String?> readMobile() => _storage.readMobile();
|
||||||
|
|
||||||
Future<bool> hasToken() async {
|
Future<bool> hasToken() async {
|
||||||
final t = await _storage.read();
|
final t = await _storage.read();
|
||||||
return t != null && t.isNotEmpty;
|
return t != null && t.isNotEmpty;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class AuthRepositoryImpl extends AuthRepository {
|
|||||||
return const DataError('پاسخ نامعتبر از سرور');
|
return const DataError('پاسخ نامعتبر از سرور');
|
||||||
}
|
}
|
||||||
await local.saveToken(token);
|
await local.saveToken(token);
|
||||||
|
await local.saveMobile(params.mobile); // برای payloadِ خریدِ فروشگاهی
|
||||||
return DataSuccess(UserModel.fromJson(
|
return DataSuccess(UserModel.fromJson(
|
||||||
Map<String, dynamic>.from(res.data['user'] as Map)));
|
Map<String, dynamic>.from(res.data['user'] as Map)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../../core/locator/locator.dart';
|
import '../../../../core/locator/locator.dart';
|
||||||
@@ -5,8 +7,9 @@ import '../../../../core/theme/app_theme.dart';
|
|||||||
import '../../data/data_source/remote/chat_api_provider.dart';
|
import '../../data/data_source/remote/chat_api_provider.dart';
|
||||||
import '../../domain/entities/chat_pack.dart';
|
import '../../domain/entities/chat_pack.dart';
|
||||||
|
|
||||||
/// پنلِ «بسته چت» شبیه تصویرِ مرجع: هدرِ ربانِ طلایی، تب برای هر بسته، و گریدِ
|
/// پنلِ «بسته چت»: قابِ لاجوردیِ طلاکوب، تبِ حبّهایِ هر بسته (با قفلِ بستههای
|
||||||
/// پیامها/شکلکها. بستههای قفل (نخریده) با دکمهی خرید (سکه/VIP) نشان داده میشوند.
|
/// نخریده)، و گریدِ پیام/شکلک. بستههای قفل با محوکردنِ گرید و کارتِ خرید نمایش
|
||||||
|
/// داده میشوند (سکه/VIP).
|
||||||
class ChatPanel extends StatefulWidget {
|
class ChatPanel extends StatefulWidget {
|
||||||
final void Function(String text) onText;
|
final void Function(String text) onText;
|
||||||
final void Function(String emoji) onEmoji;
|
final void Function(String emoji) onEmoji;
|
||||||
@@ -26,7 +29,7 @@ class ChatPanel extends StatefulWidget {
|
|||||||
}) {
|
}) {
|
||||||
return showDialog(
|
return showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierColor: Colors.black87,
|
barrierColor: Colors.black.withValues(alpha: 0.6),
|
||||||
builder: (_) => ChatPanel(
|
builder: (_) => ChatPanel(
|
||||||
onText: onText,
|
onText: onText,
|
||||||
onEmoji: onEmoji,
|
onEmoji: onEmoji,
|
||||||
@@ -83,21 +86,26 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 40),
|
insetPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 40),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 440),
|
||||||
child: FutureBuilder<List<ChatPack>>(
|
child: FutureBuilder<List<ChatPack>>(
|
||||||
future: _future,
|
future: _future,
|
||||||
builder: (context, snap) {
|
builder: (context, snap) {
|
||||||
if (snap.connectionState != ConnectionState.done) {
|
if (snap.connectionState != ConnectionState.done) {
|
||||||
return const SizedBox(
|
return _shell(const SizedBox(
|
||||||
height: 200,
|
height: 260,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: CircularProgressIndicator(color: AppColors.gold)),
|
child: CircularProgressIndicator(color: AppColors.gold)),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
final packs = snap.data ?? const <ChatPack>[];
|
final packs = snap.data ?? const <ChatPack>[];
|
||||||
if (packs.isEmpty) {
|
if (packs.isEmpty) {
|
||||||
return _shell(const Center(
|
return _shell(const SizedBox(
|
||||||
|
height: 200,
|
||||||
|
child: Center(
|
||||||
child: Text('بستهای موجود نیست',
|
child: Text('بستهای موجود نیست',
|
||||||
style: TextStyle(color: Colors.white70))));
|
style: TextStyle(color: Colors.white70))),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return DefaultTabController(
|
return DefaultTabController(
|
||||||
length: packs.length,
|
length: packs.length,
|
||||||
@@ -105,22 +113,8 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
TabBar(
|
_tabs(packs),
|
||||||
isScrollable: true,
|
const SizedBox(height: 12),
|
||||||
tabAlignment: TabAlignment.center,
|
|
||||||
indicator: BoxDecoration(
|
|
||||||
color: AppColors.lapis,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
border: Border.all(color: AppColors.gold, width: 1.4),
|
|
||||||
),
|
|
||||||
indicatorSize: TabBarIndicatorSize.tab,
|
|
||||||
labelColor: AppColors.gold,
|
|
||||||
unselectedLabelColor: Colors.white70,
|
|
||||||
labelStyle: const TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
dividerColor: Colors.transparent,
|
|
||||||
tabs: [for (final p in packs) Tab(text: p.title)],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 320,
|
height: 320,
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
@@ -133,25 +127,96 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// قابِ قرمزِ پنل با ربانِ طلاییِ «بسته چت» و دکمهی بستن.
|
// تبِ حبّهای؛ بستههای قفل یک قفلِ کوچک کنارِ عنوان دارند.
|
||||||
|
Widget _tabs(List<ChatPack> packs) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: TabBar(
|
||||||
|
isScrollable: true,
|
||||||
|
tabAlignment: TabAlignment.start,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||||
|
indicator: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
colors: [AppColors.lapis, AppColors.lapisHi],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
border: Border.all(color: AppColors.gold, width: 1.3),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColors.gold.withValues(alpha: 0.25),
|
||||||
|
blurRadius: 8,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
|
labelColor: AppColors.gold,
|
||||||
|
unselectedLabelColor: Colors.white60,
|
||||||
|
labelStyle: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
|
||||||
|
unselectedLabelStyle: const TextStyle(fontSize: 13),
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
overlayColor: WidgetStateProperty.all(Colors.transparent),
|
||||||
|
tabs: [
|
||||||
|
for (final p in packs)
|
||||||
|
Tab(
|
||||||
|
height: 36,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
p.isEmoji
|
||||||
|
? Icons.emoji_emotions_outlined
|
||||||
|
: Icons.chat_bubble_outline,
|
||||||
|
size: 15,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Text(p.title),
|
||||||
|
if (!p.owned) ...[
|
||||||
|
const SizedBox(width: 5),
|
||||||
|
Icon(
|
||||||
|
p.vip ? Icons.workspace_premium : Icons.lock,
|
||||||
|
size: 13,
|
||||||
|
color: AppColors.gold,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// قابِ لاجوردیِ پنل با ربانِ طلاییِ «بسته چت» و دکمهی بستن.
|
||||||
Widget _shell(Widget child) {
|
Widget _shell(Widget child) {
|
||||||
return Stack(
|
return Stack(
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 18),
|
margin: const EdgeInsets.only(top: 20),
|
||||||
padding: const EdgeInsets.fromLTRB(12, 30, 12, 14),
|
padding: const EdgeInsets.fromLTRB(14, 34, 14, 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [AppColors.lapisMid, AppColors.lapisLo],
|
colors: [AppColors.lapisMid, AppColors.lapisLo],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(22),
|
||||||
border: Border.all(color: AppColors.gold, width: 2),
|
border: Border.all(color: AppColors.gold, width: 1.6),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.5),
|
||||||
|
blurRadius: 24,
|
||||||
|
offset: const Offset(0, 12),
|
||||||
|
),
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColors.gold.withValues(alpha: 0.12),
|
||||||
|
blurRadius: 20,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
@@ -163,31 +228,57 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 28, vertical: 6),
|
const EdgeInsets.symmetric(horizontal: 26, vertical: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
colors: [AppColors.gold, AppColors.goldDark],
|
colors: [AppColors.gold, AppColors.goldDark],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(14),
|
||||||
border: Border.all(color: Colors.white24),
|
border: Border.all(color: Colors.white.withValues(alpha: 0.35)),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: AppColors.goldDark.withValues(alpha: 0.5),
|
||||||
|
blurRadius: 10,
|
||||||
|
offset: const Offset(0, 4),
|
||||||
),
|
),
|
||||||
child: const Text('بسته چت',
|
],
|
||||||
|
),
|
||||||
|
child: const Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.forum_rounded,
|
||||||
|
color: AppColors.lapisInk, size: 18),
|
||||||
|
SizedBox(width: 7),
|
||||||
|
Text('بسته چت',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.lapisInk,
|
color: AppColors.lapisInk,
|
||||||
fontSize: 17,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 14,
|
top: 12,
|
||||||
right: 6,
|
right: 4,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => Navigator.pop(context),
|
onTap: () => Navigator.pop(context),
|
||||||
child: const CircleAvatar(
|
child: Container(
|
||||||
radius: 15,
|
width: 30,
|
||||||
backgroundColor: AppColors.accent,
|
height: 30,
|
||||||
child: Icon(Icons.close, color: Colors.white, size: 18),
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.accent,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(color: Colors.white.withValues(alpha: 0.4)),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.4),
|
||||||
|
blurRadius: 6,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.close, color: Colors.white, size: 18),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -198,57 +289,116 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
Widget _packView(ChatPack p) {
|
Widget _packView(ChatPack p) {
|
||||||
final grid = p.isEmoji ? _emojiGrid(p) : _textGrid(p);
|
final grid = p.isEmoji ? _emojiGrid(p) : _textGrid(p);
|
||||||
if (p.owned) return grid;
|
if (p.owned) return grid;
|
||||||
// بستهی قفل: گرید کمرنگ + دکمهی خرید روی آن.
|
// بستهی قفل: گریدِ محو (blur) + کارتِ خرید روی آن.
|
||||||
return Stack(
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
child: Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
IgnorePointer(child: Opacity(opacity: 0.35, child: grid)),
|
IgnorePointer(child: Opacity(opacity: 0.5, child: grid)),
|
||||||
|
BackdropFilter(
|
||||||
|
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
|
||||||
|
child: Container(color: AppColors.lapisLo.withValues(alpha: 0.25)),
|
||||||
|
),
|
||||||
Center(child: _buyCard(p)),
|
Center(child: _buyCard(p)),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buyCard(ChatPack p) {
|
Widget _buyCard(ChatPack p) {
|
||||||
final busy = _busyPack == p.id;
|
final busy = _busyPack == p.id;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.fromLTRB(20, 22, 20, 20),
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 24),
|
margin: const EdgeInsets.symmetric(horizontal: 28),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.lapisLo.withValues(alpha: 0.9),
|
gradient: const LinearGradient(
|
||||||
borderRadius: BorderRadius.circular(14),
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: [AppColors.lapisHi, AppColors.lapisLo],
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(18),
|
||||||
border: Border.all(color: AppColors.gold, width: 1.5),
|
border: Border.all(color: AppColors.gold, width: 1.5),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.45),
|
||||||
|
blurRadius: 16,
|
||||||
|
offset: const Offset(0, 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.gold.withValues(alpha: 0.12),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(color: AppColors.goldFaint),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
p.vip ? Icons.workspace_premium : Icons.lock,
|
||||||
|
color: AppColors.gold,
|
||||||
|
size: 28,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
p.vip ? 'ویژهی اعضای VIP' : 'این بسته قفل است',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
if (p.vip)
|
if (p.vip)
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.only(bottom: 10),
|
padding: EdgeInsets.only(top: 4),
|
||||||
child: Text('این بسته برای بازیکنان VIP رایگان است!',
|
child: Text('برای اعضای VIP رایگان است',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(color: AppColors.gold, fontSize: 13)),
|
style: TextStyle(color: AppColors.gold, fontSize: 12)),
|
||||||
),
|
),
|
||||||
ElevatedButton.icon(
|
const SizedBox(height: 16),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppColors.success,
|
backgroundColor: AppColors.success,
|
||||||
minimumSize: const Size(160, 46),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(14),
|
||||||
side: const BorderSide(color: AppColors.gold, width: 1.4),
|
side: const BorderSide(color: AppColors.gold, width: 1.3),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: busy ? null : () => _buy(p),
|
onPressed: busy ? null : () => _buy(p),
|
||||||
icon: busy
|
child: busy
|
||||||
? const SizedBox(
|
? const SizedBox(
|
||||||
width: 18,
|
width: 20,
|
||||||
height: 18,
|
height: 20,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
strokeWidth: 2, color: Colors.white))
|
strokeWidth: 2.2, color: Colors.white))
|
||||||
: const Icon(Icons.monetization_on, color: AppColors.gold),
|
: Row(
|
||||||
label: Text('${p.priceCoins}',
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Text('خرید',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
const Icon(Icons.monetization_on,
|
||||||
|
color: AppColors.gold, size: 20),
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
Text('${p.priceCoins}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 16,
|
fontSize: 15,
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -257,32 +407,51 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
|
|
||||||
Widget _textGrid(ChatPack p) => GridView.count(
|
Widget _textGrid(ChatPack p) => GridView.count(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
padding: const EdgeInsets.all(4),
|
padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 4),
|
||||||
childAspectRatio: 2.7,
|
childAspectRatio: 2.7,
|
||||||
mainAxisSpacing: 10,
|
mainAxisSpacing: 10,
|
||||||
crossAxisSpacing: 10,
|
crossAxisSpacing: 10,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
children: [
|
children: [
|
||||||
for (final m in p.messages)
|
for (final m in p.messages)
|
||||||
GestureDetector(
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
onTap: p.owned ? () => _pick(p, m) : null,
|
onTap: p.owned ? () => _pick(p, m) : null,
|
||||||
child: Container(
|
child: Ink(
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
begin: Alignment.topCenter,
|
begin: Alignment.topCenter,
|
||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [AppColors.lapisHi, AppColors.lapisLo],
|
colors: [AppColors.lapisHi, AppColors.lapisLo],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(12),
|
||||||
border: Border.all(color: AppColors.goldDark, width: 1.2),
|
border:
|
||||||
|
Border.all(color: AppColors.goldDark, width: 1.1),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withValues(alpha: 0.3),
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: const Offset(0, 3),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
child: Text(m,
|
child: Text(m,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white, fontWeight: FontWeight.bold)),
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 13.5)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -291,13 +460,27 @@ class _ChatPanelState extends State<ChatPanel> {
|
|||||||
Widget _emojiGrid(ChatPack p) => GridView.count(
|
Widget _emojiGrid(ChatPack p) => GridView.count(
|
||||||
crossAxisCount: 5,
|
crossAxisCount: 5,
|
||||||
padding: const EdgeInsets.all(6),
|
padding: const EdgeInsets.all(6),
|
||||||
|
mainAxisSpacing: 8,
|
||||||
|
crossAxisSpacing: 8,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
children: [
|
children: [
|
||||||
for (final e in p.messages)
|
for (final e in p.messages)
|
||||||
InkWell(
|
Material(
|
||||||
borderRadius: BorderRadius.circular(12),
|
color: Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
onTap: p.owned ? () => _pick(p, e) : null,
|
onTap: p.owned ? () => _pick(p, e) : null,
|
||||||
child:
|
child: Ink(
|
||||||
Center(child: Text(e, style: const TextStyle(fontSize: 32))),
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.lapisHi.withValues(alpha: 0.55),
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
border: Border.all(color: AppColors.goldFaint),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(e, style: const TextStyle(fontSize: 30))),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class GamePlayer {
|
|||||||
final bool connected;
|
final bool connected;
|
||||||
final int coins;
|
final int coins;
|
||||||
final String rankTier; // bronze..king (خالی برای بات)
|
final String rankTier; // bronze..king (خالی برای بات)
|
||||||
|
final String avatar; // seed آواتارِ انتخابیِ کاربر (خالی برای بات)
|
||||||
|
|
||||||
GamePlayer.fromJson(Map<String, dynamic> j)
|
GamePlayer.fromJson(Map<String, dynamic> j)
|
||||||
: seat = (j['seat'] ?? 0) as int,
|
: seat = (j['seat'] ?? 0) as int,
|
||||||
@@ -14,7 +15,11 @@ class GamePlayer {
|
|||||||
bot = (j['bot'] ?? false) as bool,
|
bot = (j['bot'] ?? false) as bool,
|
||||||
connected = (j['connected'] ?? false) as bool,
|
connected = (j['connected'] ?? false) as bool,
|
||||||
coins = (j['coins'] ?? 0) as int,
|
coins = (j['coins'] ?? 0) as int,
|
||||||
rankTier = (j['rank_tier'] ?? '') as String;
|
rankTier = (j['rank_tier'] ?? '') as String,
|
||||||
|
avatar = (j['avatar'] ?? '') as String;
|
||||||
|
|
||||||
|
/// seedِ آواتار برای نمایش: آواتارِ انتخابی، وگرنه نام (fallback برای بات).
|
||||||
|
String get avatarSeed => avatar.isNotEmpty ? avatar : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TrickCard {
|
class TrickCard {
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ import '../../domain/entities/game_entities.dart';
|
|||||||
/// یک بازیکن در اتاق انتظارِ میز خصوصی.
|
/// یک بازیکن در اتاق انتظارِ میز خصوصی.
|
||||||
class LobbyPlayer {
|
class LobbyPlayer {
|
||||||
final String name;
|
final String name;
|
||||||
|
final String avatar; // seed آواتارِ انتخابیِ کاربر
|
||||||
final bool host;
|
final bool host;
|
||||||
final int seat; // جایگاهِ مطلق (۰..۳)
|
final int seat; // جایگاهِ مطلق (۰..۳)
|
||||||
const LobbyPlayer(this.name, this.host, this.seat);
|
const LobbyPlayer(this.name, this.avatar, this.host, this.seat);
|
||||||
|
|
||||||
|
/// seedِ آواتار برای نمایش: آواتارِ انتخابی، وگرنه نام.
|
||||||
|
String get avatarSeed => avatar.isNotEmpty ? avatar : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// وضعیت اتاق انتظارِ میز خصوصی (دورهمی).
|
/// وضعیت اتاق انتظارِ میز خصوصی (دورهمی).
|
||||||
@@ -35,6 +39,7 @@ class TableLobby {
|
|||||||
players: ((j['players'] as List?) ?? [])
|
players: ((j['players'] as List?) ?? [])
|
||||||
.map((e) => LobbyPlayer(
|
.map((e) => LobbyPlayer(
|
||||||
(e['name'] ?? '') as String,
|
(e['name'] ?? '') as String,
|
||||||
|
(e['avatar'] ?? '') as String,
|
||||||
(e['host'] ?? false) as bool,
|
(e['host'] ?? false) as bool,
|
||||||
(e['seat'] ?? 0) as int,
|
(e['seat'] ?? 0) as int,
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ class _GameScreenState extends State<GameScreen> {
|
|||||||
)
|
)
|
||||||
: ClipRRect(
|
: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: RandomAvatar(p.name),
|
child: RandomAvatar(p.avatarSeed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ class _LobbyViewState extends State<_LobbyView> {
|
|||||||
)
|
)
|
||||||
: ClipRRect(
|
: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(9),
|
borderRadius: BorderRadius.circular(9),
|
||||||
child: RandomAvatar(p.name),
|
child: RandomAvatar(p.avatarSeed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!empty)
|
if (!empty)
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class HokmGame extends FlameGame {
|
|||||||
bool _beatPlayed = false; // اولین ضربان در پنجرهی پایانیِ نوبت پخش شد
|
bool _beatPlayed = false; // اولین ضربان در پنجرهی پایانیِ نوبت پخش شد
|
||||||
double _hbAccum = 0; // انباشتِ زمان برای تکرارِ منظمِ ضربان تا پایانِ نوبت
|
double _hbAccum = 0; // انباشتِ زمان برای تکرارِ منظمِ ضربان تا پایانِ نوبت
|
||||||
bool _wasMyTurn = false;
|
bool _wasMyTurn = false;
|
||||||
|
String _turnSig = ''; // امضای نوبت (نوبت|تعدادِ کارتِ زمین|فاز) — همگام با HUD
|
||||||
|
|
||||||
/// فرشِ انتخابی؛ 'classic' یعنی سطحِ میزِ ترسیمی. فرشِ تصویری بهعنوانِ سطحِ
|
/// فرشِ انتخابی؛ 'classic' یعنی سطحِ میزِ ترسیمی. فرشِ تصویری بهعنوانِ سطحِ
|
||||||
/// میز (بریده در شکلِ میز) روی زمینِ لاجوردی کشیده میشود.
|
/// میز (بریده در شکلِ میز) روی زمینِ لاجوردی کشیده میشود.
|
||||||
@@ -271,34 +272,47 @@ class HokmGame extends FlameGame {
|
|||||||
|
|
||||||
// ضربانِ قلب فقط در ثانیههای پایانیِ نوبتِ خودِ کاربر؛ هنگامِ پایانِ نوبت
|
// ضربانِ قلب فقط در ثانیههای پایانیِ نوبتِ خودِ کاربر؛ هنگامِ پایانِ نوبت
|
||||||
// (بازیشدنِ کارت توسط کاربر یا سیستم) بلافاصله قطع میشود.
|
// (بازیشدنِ کارت توسط کاربر یا سیستم) بلافاصله قطع میشود.
|
||||||
|
//
|
||||||
|
// زمانسنجِ نوبت باید دقیقاً همزمان با «حلقهی زمانِ نوبت» در HUD شروع شود؛
|
||||||
|
// آن حلقه با تغییرِ امضای نوبت (نوبت|تعدادِ کارتِ زمین|فاز) ریست میشود و به
|
||||||
|
// انیمیشنِ بُر/پخش کاری ندارد. پس اینجا هم شمارش را به همان امضا میبندیم و
|
||||||
|
// فقط «پخشِ صدا» را در حینِ انیمیشن/اینترو خاموش میکنیم تا صدا و تصویر یکی شوند.
|
||||||
void _updateHeartBeat(double dt) {
|
void _updateHeartBeat(double dt) {
|
||||||
final s = _s;
|
final s = _s;
|
||||||
final myTurn = !_silent &&
|
final isMyTurn = s != null &&
|
||||||
!_introActive &&
|
|
||||||
!_shuffling &&
|
|
||||||
s != null &&
|
|
||||||
((s.phase == 'playing' && s.turn == s.yourSeat) ||
|
((s.phase == 'playing' && s.turn == s.yourSeat) ||
|
||||||
(s.phase == 'choose_trump' && s.hakem == s.yourSeat));
|
(s.phase == 'choose_trump' && s.hakem == s.yourSeat));
|
||||||
|
|
||||||
if (!myTurn) {
|
if (!isMyTurn || _silent) {
|
||||||
if (_wasMyTurn) {
|
if (_wasMyTurn) {
|
||||||
AppSounds.stopHeartBeat(); // نوبت تمام شد ⇒ توقفِ فوریِ صدا
|
AppSounds.stopHeartBeat(); // نوبت تمام شد ⇒ توقفِ فوریِ صدا
|
||||||
_wasMyTurn = false;
|
_wasMyTurn = false;
|
||||||
}
|
}
|
||||||
|
_turnSig = s == null ? '' : '${s.turn}|${s.trick.length}|${s.phase}';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_wasMyTurn) {
|
// امضای نوبت — همانی که حلقهی HUD استفاده میکند.
|
||||||
// شروعِ نوبتِ من ⇒ شمارش از صفر.
|
final sig = '${s.turn}|${s.trick.length}|${s.phase}';
|
||||||
|
if (!_wasMyTurn || sig != _turnSig) {
|
||||||
|
// شروعِ نوبتِ من (یا نوبتِ جدید) ⇒ شمارش از صفر، همزمان با حلقهی HUD.
|
||||||
_wasMyTurn = true;
|
_wasMyTurn = true;
|
||||||
|
_turnSig = sig;
|
||||||
_turnElapsed = 0;
|
_turnElapsed = 0;
|
||||||
_beatPlayed = false;
|
_beatPlayed = false;
|
||||||
_hbAccum = 0;
|
_hbAccum = 0;
|
||||||
// صدای «نوبتِ شما» فقط هنگامِ بازیِ کارت (نه پخش/انتخابِ حکم).
|
// صدای «نوبتِ شما» فقط هنگامِ بازیِ کارت و بیرون از انیمیشنها.
|
||||||
if (s.phase == 'playing' && !_dealing) AppSounds.turn();
|
if (s.phase == 'playing' && !_introActive && !_shuffling && !_dealing) {
|
||||||
|
AppSounds.turn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_turnElapsed += dt;
|
_turnElapsed += dt;
|
||||||
|
|
||||||
|
// در حینِ اینترو/بُر/پخش صدایی پخش نمیکنیم (اما شمارش ادامه دارد تا با
|
||||||
|
// حلقهی HUD همگام بماند). این انیمیشنها در ابتدای نوبتاند و با پنجرهی
|
||||||
|
// پایانیِ ضربان همپوشانی ندارند.
|
||||||
|
if (_introActive || _shuffling || _dealing) return;
|
||||||
|
|
||||||
final dur = (s.turnTimeoutMs > 0 ? s.turnTimeoutMs / 1000.0 : 30.0);
|
final dur = (s.turnTimeoutMs > 0 ? s.turnTimeoutMs / 1000.0 : 30.0);
|
||||||
final remaining = dur - _turnElapsed;
|
final remaining = dur - _turnElapsed;
|
||||||
final warn = math.min(7.0, dur * 0.4);
|
final warn = math.min(7.0, dur * 0.4);
|
||||||
|
|||||||
@@ -297,7 +297,8 @@ class _PlayerSeat extends StatelessWidget {
|
|||||||
color: Colors.white70,
|
color: Colors.white70,
|
||||||
size: diameter * 0.5,
|
size: diameter * 0.5,
|
||||||
)
|
)
|
||||||
: RandomAvatar(player.name.isEmpty ? '?' : player.name),
|
: RandomAvatar(
|
||||||
|
player.avatarSeed.isEmpty ? '?' : player.avatarSeed),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
import '../../../../core/payment/payment_gateway.dart';
|
import '../../../../core/payment/payment_gateway.dart';
|
||||||
|
import '../../../../core/storage/token_storage.dart';
|
||||||
import '../../../../core/resources/data_state.dart';
|
import '../../../../core/resources/data_state.dart';
|
||||||
import '../../../../core/usecase/use_case.dart';
|
import '../../../../core/usecase/use_case.dart';
|
||||||
import '../../domain/use_cases/ad_reward_usecase.dart';
|
import '../../domain/use_cases/ad_reward_usecase.dart';
|
||||||
@@ -19,6 +20,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
final PurchaseUseCase purchaseUseCase;
|
final PurchaseUseCase purchaseUseCase;
|
||||||
final AdRewardUseCase adRewardUseCase;
|
final AdRewardUseCase adRewardUseCase;
|
||||||
final PaymentGateway gateway;
|
final PaymentGateway gateway;
|
||||||
|
final TokenStorage storage;
|
||||||
|
|
||||||
ShopBloc(
|
ShopBloc(
|
||||||
this.getShopUseCase,
|
this.getShopUseCase,
|
||||||
@@ -27,6 +29,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
this.purchaseUseCase,
|
this.purchaseUseCase,
|
||||||
this.adRewardUseCase,
|
this.adRewardUseCase,
|
||||||
this.gateway,
|
this.gateway,
|
||||||
|
this.storage,
|
||||||
) : super(ShopBlocState.initial()) {
|
) : super(ShopBlocState.initial()) {
|
||||||
on<LoadShopEvent>((event, emit) => _load(emit));
|
on<LoadShopEvent>((event, emit) => _load(emit));
|
||||||
|
|
||||||
@@ -59,9 +62,13 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
// شناسهی کاتالوگ استفاده میکنیم (حالتِ توسعه/تکفروشگاهی).
|
// شناسهی کاتالوگ استفاده میکنیم (حالتِ توسعه/تکفروشگاهی).
|
||||||
final sku = event.sku.isNotEmpty ? event.sku : event.productId;
|
final sku = event.sku.isNotEmpty ? event.sku : event.productId;
|
||||||
|
|
||||||
|
// شمارهی موبایل را بهعنوان payload میفرستیم تا خرید در پنلِ فروشگاه
|
||||||
|
// قابلِ ردیابی باشد.
|
||||||
|
final mobile = await storage.readMobile() ?? '';
|
||||||
|
|
||||||
final PurchaseResult result;
|
final PurchaseResult result;
|
||||||
try {
|
try {
|
||||||
result = await gateway.purchase(sku);
|
result = await gateway.purchase(sku, payload: mobile);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return DataError<String>('خطا در پرداخت: $e');
|
return DataError<String>('خطا در پرداخت: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user