feat: add payment
@@ -1,13 +1,25 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "myket (debug)",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"args": ["--flavor", "myket", "--dart-define=BASE_URL=https://hakem.approagency.ir"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "bazaar (debug)",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "dart",
|
||||||
|
"args": ["--flavor", "bazaar", "--dart-define=BASE_URL=https://hakem.approagency.ir"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "حکمشو (موبایل واقعی - LAN)",
|
"name": "حکمشو (موبایل واقعی - LAN)",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"type": "dart",
|
"type": "dart",
|
||||||
"program": "lib/main.dart",
|
"program": "lib/main.dart",
|
||||||
"args": [
|
"args": [
|
||||||
"--dart-define=BASE_URL=http://192.168.1.105:8080",
|
"--dart-define=BASE_URL=https://hakem.approagency.ir",
|
||||||
"--target-platform=android-arm64"
|
"--target-platform=android-arm64"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import java.io.FileInputStream
|
||||||
|
import java.util.Properties
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("kotlin-android")
|
id("kotlin-android")
|
||||||
@@ -23,7 +26,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "ir.hakemsho.hakemsho"
|
applicationId = "com.approagency.hakemirani"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
// flutter_secure_storage حداقل SDK 23 را لازم دارد.
|
// flutter_secure_storage حداقل SDK 23 را لازم دارد.
|
||||||
@@ -31,16 +34,89 @@ android {
|
|||||||
targetSdk = flutter.targetSdkVersion
|
targetSdk = flutter.targetSdkVersion
|
||||||
versionCode = flutter.versionCode
|
versionCode = flutter.versionCode
|
||||||
versionName = flutter.versionName
|
versionName = flutter.versionName
|
||||||
|
// مقادیرِ پیشفرض تا buildِ بدونِ flavor (مثلِ `flutter run`) هم merge شود؛
|
||||||
|
// flavorها اینها را override میکنند.
|
||||||
|
manifestPlaceholders += mapOf(
|
||||||
|
"marketApplicationId" to "com.farsitel.bazaar",
|
||||||
|
"marketBindAddress" to "com.farsitel.bazaar.InAppBillingService.BIND",
|
||||||
|
"marketPermission" to "com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// یک flavor برای هر فروشگاه؛ هر کدام placeholderهای manifestِ افزونهی
|
||||||
|
// پرداخت (myket_iap / flutter_poolakey) را پر میکند. STORE بهصورتِ
|
||||||
|
// BuildConfig هم تزریق میشود تا سمتِ Dart بدونِ dart-define بداند کدام
|
||||||
|
// درگاه فعال است.
|
||||||
|
flavorDimensions += "store"
|
||||||
|
productFlavors {
|
||||||
|
create("myket") {
|
||||||
|
dimension = "store"
|
||||||
|
manifestPlaceholders += mapOf(
|
||||||
|
"marketApplicationId" to "ir.mservices.market",
|
||||||
|
"marketBindAddress" to "ir.mservices.market.InAppBillingService.BIND",
|
||||||
|
"marketPermission" to "ir.mservices.market.BILLING"
|
||||||
|
)
|
||||||
|
resValue("string", "iap_store", "myket")
|
||||||
|
}
|
||||||
|
create("bazaar") {
|
||||||
|
dimension = "store"
|
||||||
|
manifestPlaceholders += mapOf(
|
||||||
|
"marketApplicationId" to "com.farsitel.bazaar",
|
||||||
|
"marketBindAddress" to "com.farsitel.bazaar.InAppBillingService.BIND",
|
||||||
|
"marketPermission" to "com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR"
|
||||||
|
)
|
||||||
|
resValue("string", "iap_store", "bazaar")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
create("release") {
|
||||||
|
keyAlias = keystoreProperties["keyAlias"] as String?
|
||||||
|
keyPassword = keystoreProperties["keyPassword"] as String?
|
||||||
|
storeFile = keystoreProperties["storeFile"]?.let {
|
||||||
|
file(it)
|
||||||
|
}
|
||||||
|
storePassword = keystoreProperties["storePassword"] as String?
|
||||||
|
}
|
||||||
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
// TODO: Add your own signing config for the release build.
|
// TODO: Add your own signing config for the release build.
|
||||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
signingConfig = signingConfigs.getByName("debug")
|
signingConfig = signingConfigs.getByName("debug")
|
||||||
|
getByName("release") {
|
||||||
|
signingConfig = signingConfigs.getByName("release")
|
||||||
|
isMinifyEnabled = true
|
||||||
|
isShrinkResources = true
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// هر دو افزونهی پرداخت کلاسِ AIDLِ یکسانِ
|
||||||
|
// `com.android.vending.billing.IInAppBillingService` را در AARِ خود دارند؛ چون
|
||||||
|
// هر دو پکیجِ Dart همیشه در classpath هستند، هر flavor هر دو AAR را میکشد و
|
||||||
|
// «Duplicate class» میدهد. راهحل: از هر flavor فقط کتابخانهی فروشگاهِ خودش را
|
||||||
|
// نگه میداریم و کتابخانهی فروشگاهِ دیگر را حذف میکنیم (در آن flavor صدا زده
|
||||||
|
// نمیشود).
|
||||||
|
configurations.configureEach {
|
||||||
|
if (name.startsWith("myket")) {
|
||||||
|
exclude(group = "com.github.cafebazaar.Poolakey")
|
||||||
|
}
|
||||||
|
if (name.startsWith("bazaar")) {
|
||||||
|
exclude(group = "com.github.myketstore")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
flutter {
|
flutter {
|
||||||
source = "../.."
|
source = "../.."
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# هر flavor فقط کتابخانهی پرداختِ فروشگاهِ خودش را دارد (کتابخانهی فروشگاهِ
|
||||||
|
# دیگر در build.gradle.kts حذف شده تا «Duplicate class» رخ ندهد). در نتیجه،
|
||||||
|
# کلاسِ افزونهی فروشگاهِ غایب به کلاسهایی ارجاع میدهد که در آن flavor نیستند؛
|
||||||
|
# چون در آن flavor صدا زده نمیشوند، به R8 میگوییم دربارهشان هشدار ندهد.
|
||||||
|
-dontwarn ir.cafebazaar.poolakey.**
|
||||||
|
-dontwarn ir.myket.billingclient.**
|
||||||
|
|
||||||
|
# افزونههای پرداخت و کلاسهای billing را دستنخورده نگه دار.
|
||||||
|
-keep class ir.cafebazaar.flutter_poolakey.** { *; }
|
||||||
|
-keep class ir.mservices.myketiap.** { *; }
|
||||||
|
-keep class ir.cafebazaar.poolakey.** { *; }
|
||||||
|
-keep class ir.myket.billingclient.** { *; }
|
||||||
|
-keep class com.android.vending.billing.** { *; }
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<application
|
<application
|
||||||
android:label="hakemsho"
|
android:label="حاکم ایرانی"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 87 KiB |
@@ -121,7 +121,7 @@ class HakemApp extends StatelessWidget {
|
|||||||
BlocProvider(create: (_) => locator<WalletBloc>()),
|
BlocProvider(create: (_) => locator<WalletBloc>()),
|
||||||
],
|
],
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
title: 'سلطان حکم',
|
title: 'حاکم ایرانی',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: AppTheme.build(),
|
theme: AppTheme.build(),
|
||||||
routerConfig: router,
|
routerConfig: router,
|
||||||
|
|||||||
@@ -1,5 +1,24 @@
|
|||||||
|
import 'package:flutter/services.dart' show appFlavor;
|
||||||
|
|
||||||
/// تنظیمات سراسری اپ.
|
/// تنظیمات سراسری اپ.
|
||||||
class AppConfig {
|
class AppConfig {
|
||||||
|
/// فروشگاهِ فعال از روی `--flavor` که اپ با آن ساخته شده
|
||||||
|
/// (`myket` | `bazaar`). اگر بدونِ flavor اجرا شود، `dev`.
|
||||||
|
static String get store => appFlavor ?? 'dev';
|
||||||
|
|
||||||
|
/// کلیدِ عمومیِ RSA مایکت (برای تأییدِ محلیِ افزونهی myket_iap).
|
||||||
|
static const String myketRsaKey = String.fromEnvironment(
|
||||||
|
'MYKET_RSA',
|
||||||
|
defaultValue:
|
||||||
|
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVCtWUXVZfxULqP3QKlTqsXYkqg5qJYf6KnRSsyk7STB223Ji95IonwHrSrheffrPXi4othieBwl7rDaP0KnvkZ0Le0kr7xHCgTQgYeRuPq15HMm9mrFaXD3HgTF27f1/DcAN8z7eE02ShwAjd0LjYC2u2+T6z8iuQ2oh9LbJPnQIDAQAB',
|
||||||
|
);
|
||||||
|
|
||||||
|
/// کلیدِ عمومیِ RSA کافهبازار (از پنلِ توسعهدهندهی بازار).
|
||||||
|
static const String bazaarRsaKey = String.fromEnvironment(
|
||||||
|
'BAZAAR_RSA',
|
||||||
|
defaultValue: '',
|
||||||
|
);
|
||||||
|
|
||||||
/// آدرس پایهی سرور.
|
/// آدرس پایهی سرور.
|
||||||
/// - موبایل واقعی روی همان Wi-Fi: IP محلی مک (پیشفرض فعلی).
|
/// - موبایل واقعی روی همان Wi-Fi: IP محلی مک (پیشفرض فعلی).
|
||||||
/// - امولاتور اندروید: `--dart-define=BASE_URL=http://10.0.2.2:8080`
|
/// - امولاتور اندروید: `--dart-define=BASE_URL=http://10.0.2.2:8080`
|
||||||
@@ -8,7 +27,7 @@ class AppConfig {
|
|||||||
/// با تغییر شبکه/IP مک، مقدار dart-define یا همین پیشفرض را عوض کنید.
|
/// با تغییر شبکه/IP مک، مقدار dart-define یا همین پیشفرض را عوض کنید.
|
||||||
static const String baseUrl = String.fromEnvironment(
|
static const String baseUrl = String.fromEnvironment(
|
||||||
'BASE_URL',
|
'BASE_URL',
|
||||||
defaultValue: 'http://192.168.1.105:8080',
|
defaultValue: 'https://hakem.approagency.ir',
|
||||||
);
|
);
|
||||||
|
|
||||||
static String get apiUrl => '$baseUrl/api';
|
static String get apiUrl => '$baseUrl/api';
|
||||||
|
|||||||
@@ -46,7 +46,12 @@ import '../../feature/wallet/domain/repository/wallet_repository.dart';
|
|||||||
import '../../feature/wallet/domain/use_cases/claim_daily_usecase.dart';
|
import '../../feature/wallet/domain/use_cases/claim_daily_usecase.dart';
|
||||||
import '../../feature/wallet/domain/use_cases/get_wallet_usecase.dart';
|
import '../../feature/wallet/domain/use_cases/get_wallet_usecase.dart';
|
||||||
import '../../feature/wallet/presentation/bloc/wallet_bloc.dart';
|
import '../../feature/wallet/presentation/bloc/wallet_bloc.dart';
|
||||||
|
import '../config.dart';
|
||||||
import '../network/api_provider_imp.dart';
|
import '../network/api_provider_imp.dart';
|
||||||
|
import '../payment/bazaar_payment_gateway.dart';
|
||||||
|
import '../payment/dev_payment_gateway.dart';
|
||||||
|
import '../payment/myket_payment_gateway.dart';
|
||||||
|
import '../payment/payment_gateway.dart';
|
||||||
import '../storage/token_storage.dart';
|
import '../storage/token_storage.dart';
|
||||||
|
|
||||||
final GetIt locator = GetIt.instance;
|
final GetIt locator = GetIt.instance;
|
||||||
@@ -94,6 +99,9 @@ Future<void> setupLocator() async {
|
|||||||
locator.registerSingleton<SelectCardUseCase>(SelectCardUseCase(locator()));
|
locator.registerSingleton<SelectCardUseCase>(SelectCardUseCase(locator()));
|
||||||
locator.registerSingleton<PurchaseUseCase>(PurchaseUseCase(locator()));
|
locator.registerSingleton<PurchaseUseCase>(PurchaseUseCase(locator()));
|
||||||
locator.registerSingleton<AdRewardUseCase>(AdRewardUseCase(locator()));
|
locator.registerSingleton<AdRewardUseCase>(AdRewardUseCase(locator()));
|
||||||
|
|
||||||
|
// درگاهِ پرداخت بر اساسِ flavorِ فعال (مایکت/کافهبازار/توسعه).
|
||||||
|
locator.registerSingleton<PaymentGateway>(_gatewayForStore(AppConfig.store));
|
||||||
locator.registerSingleton<GetProfileUseCase>(GetProfileUseCase(locator()));
|
locator.registerSingleton<GetProfileUseCase>(GetProfileUseCase(locator()));
|
||||||
locator.registerSingleton<SaveProfileUseCase>(SaveProfileUseCase(locator()));
|
locator.registerSingleton<SaveProfileUseCase>(SaveProfileUseCase(locator()));
|
||||||
locator.registerSingleton<GetLeaderboardUseCase>(
|
locator.registerSingleton<GetLeaderboardUseCase>(
|
||||||
@@ -106,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>(() =>
|
locator.registerFactory<ShopBloc>(() => ShopBloc(
|
||||||
ShopBloc(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()));
|
||||||
@@ -115,3 +123,16 @@ Future<void> setupLocator() async {
|
|||||||
locator.registerFactory<TierBloc>(() => TierBloc(locator()));
|
locator.registerFactory<TierBloc>(() => TierBloc(locator()));
|
||||||
locator.registerFactory<PrivateInfoBloc>(() => PrivateInfoBloc(locator()));
|
locator.registerFactory<PrivateInfoBloc>(() => PrivateInfoBloc(locator()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// درگاهِ پرداختِ متناظر با flavor. buildهای بدونِ flavor از درگاهِ توسعه
|
||||||
|
/// استفاده میکنند (بکاند در DevFallback میپذیرد).
|
||||||
|
PaymentGateway _gatewayForStore(String store) {
|
||||||
|
switch (store) {
|
||||||
|
case 'myket':
|
||||||
|
return MyketPaymentGateway();
|
||||||
|
case 'bazaar':
|
||||||
|
return BazaarPaymentGateway();
|
||||||
|
default:
|
||||||
|
return DevPaymentGateway();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter_poolakey/flutter_poolakey.dart';
|
||||||
|
|
||||||
|
import '../config.dart';
|
||||||
|
import 'payment_gateway.dart';
|
||||||
|
|
||||||
|
/// پرداختِ درونبرنامهایِ کافهبازار (Poolakey) — flavorِ `bazaar`.
|
||||||
|
class BazaarPaymentGateway implements PaymentGateway {
|
||||||
|
bool _connected = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get store => 'bazaar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> connect() async {
|
||||||
|
if (_connected) return;
|
||||||
|
await FlutterPoolakey.connect(
|
||||||
|
AppConfig.bazaarRsaKey,
|
||||||
|
onDisconnected: () => _connected = false,
|
||||||
|
);
|
||||||
|
_connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PurchaseResult> purchase(String productSku) async {
|
||||||
|
try {
|
||||||
|
await connect();
|
||||||
|
final info = await FlutterPoolakey.purchase(
|
||||||
|
productSku,
|
||||||
|
payload: 'hakemsho',
|
||||||
|
);
|
||||||
|
if (info.purchaseToken.isEmpty) {
|
||||||
|
return const PurchaseResult.failure();
|
||||||
|
}
|
||||||
|
return PurchaseResult.success(
|
||||||
|
token: info.purchaseToken,
|
||||||
|
purchaseData: info.originalJson,
|
||||||
|
signature: info.dataSignature,
|
||||||
|
// کالای مصرفی باید مصرف شود تا خریدِ مجدد ممکن باشد.
|
||||||
|
onConfirmed: () => FlutterPoolakey.consume(info.purchaseToken),
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
// کنسلشدن یا خطای بازار ⇒ شکستِ خرید.
|
||||||
|
return const PurchaseResult.failure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import 'payment_gateway.dart';
|
||||||
|
|
||||||
|
/// درگاهِ توسعه: بدونِ اتصال به فروشگاه، یک توکنِ ساختگی میسازد. برای اجرای
|
||||||
|
/// معمولیِ `flutter run` (بدونِ flavor) استفاده میشود؛ بکاند در حالتِ
|
||||||
|
/// DevFallback آن را میپذیرد.
|
||||||
|
class DevPaymentGateway implements PaymentGateway {
|
||||||
|
@override
|
||||||
|
String get store => 'dev';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> connect() async {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PurchaseResult> purchase(String productSku) async {
|
||||||
|
final stamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
return PurchaseResult.success(
|
||||||
|
token: 'dev-$productSku-$stamp',
|
||||||
|
purchaseData: '{"productId":"$productSku","purchaseToken":"dev-$stamp"}',
|
||||||
|
signature: 'dev',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import 'package:myket_iap/myket_iap.dart';
|
||||||
|
import 'package:myket_iap/util/purchase.dart';
|
||||||
|
|
||||||
|
import '../config.dart';
|
||||||
|
import 'payment_gateway.dart';
|
||||||
|
|
||||||
|
/// پرداختِ درونبرنامهایِ مایکت (flavorِ `myket`).
|
||||||
|
class MyketPaymentGateway implements PaymentGateway {
|
||||||
|
bool _inited = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get store => 'myket';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> connect() async {
|
||||||
|
if (_inited) return;
|
||||||
|
await MyketIAP.init(rsaKey: AppConfig.myketRsaKey, enableDebugLogging: false);
|
||||||
|
_inited = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<PurchaseResult> purchase(String productSku) async {
|
||||||
|
await connect();
|
||||||
|
final Map<dynamic, dynamic> result =
|
||||||
|
await MyketIAP.launchPurchaseFlow(sku: productSku, payload: 'hakemsho');
|
||||||
|
|
||||||
|
final Purchase? purchase = result[MyketIAP.PURCHASE] as Purchase?;
|
||||||
|
if (purchase == null || purchase.mToken.isEmpty) {
|
||||||
|
return const PurchaseResult.failure();
|
||||||
|
}
|
||||||
|
|
||||||
|
return PurchaseResult.success(
|
||||||
|
token: purchase.mToken,
|
||||||
|
purchaseData: purchase.mOriginalJson,
|
||||||
|
signature: purchase.mSignature,
|
||||||
|
// کالای مصرفی (سکه/بلیت) باید مصرف شود تا کاربر بتواند دوباره بخرد.
|
||||||
|
onConfirmed: () => MyketIAP.consume(purchase: purchase),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/// نتیجهی یک خریدِ فروشگاهی، مستقل از اینکه کدام SDK آن را تولید کرده.
|
||||||
|
///
|
||||||
|
/// بکاند برای تأییدِ آفلاینِ RSA به [purchaseData] (JSONِ خام) و [signature]
|
||||||
|
/// نیاز دارد؛ [token] هم برای تأییدِ سمتسرور/سازگاری فرستاده میشود.
|
||||||
|
class PurchaseResult {
|
||||||
|
final bool success;
|
||||||
|
final String token;
|
||||||
|
final String purchaseData;
|
||||||
|
final String signature;
|
||||||
|
|
||||||
|
/// پاکسازیِ لازم پس از تأییدِ بکاند (مثلاً مایکت باید خرید را consume کند).
|
||||||
|
final Future<void> Function()? onConfirmed;
|
||||||
|
|
||||||
|
const PurchaseResult.success({
|
||||||
|
required this.token,
|
||||||
|
required this.purchaseData,
|
||||||
|
required this.signature,
|
||||||
|
this.onConfirmed,
|
||||||
|
}) : success = true;
|
||||||
|
|
||||||
|
const PurchaseResult.failure()
|
||||||
|
: success = false,
|
||||||
|
token = '',
|
||||||
|
purchaseData = '',
|
||||||
|
signature = '',
|
||||||
|
onConfirmed = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// انتزاعِ SDKِ پرداختِ درونبرنامهایِ مخصوصِ هر فروشگاه. هر flavor یک پیادهسازی
|
||||||
|
/// ثبت میکند؛ بقیهی اپ از SDK بیخبر میماند.
|
||||||
|
abstract class PaymentGateway {
|
||||||
|
/// شناسهی فروشگاه که به بکاند فرستاده میشود (`myket` | `bazaar`).
|
||||||
|
String get store;
|
||||||
|
|
||||||
|
/// جریانِ خریدِ [productSku] (همان UUIDِ محصول در پنلِ فروشگاه) را باز میکند.
|
||||||
|
Future<PurchaseResult> purchase(String productSku);
|
||||||
|
|
||||||
|
/// اتصالِ اولیه (در صورتِ نیاز). پیش از اولین خرید صدا زده میشود.
|
||||||
|
Future<void> connect() async {}
|
||||||
|
}
|
||||||
@@ -28,10 +28,14 @@ class PurchaseParams {
|
|||||||
final String kind;
|
final String kind;
|
||||||
final String productId;
|
final String productId;
|
||||||
final String token;
|
final String token;
|
||||||
|
final String purchaseData;
|
||||||
|
final String signature;
|
||||||
const PurchaseParams({
|
const PurchaseParams({
|
||||||
required this.store,
|
required this.store,
|
||||||
required this.kind,
|
required this.kind,
|
||||||
required this.productId,
|
required this.productId,
|
||||||
required this.token,
|
required this.token,
|
||||||
|
this.purchaseData = '',
|
||||||
|
this.signature = '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class _MobileScreenState extends State<MobileScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const GlowText('سلطان حکم', size: 40),
|
const GlowText('حاکم ایرانی', size: 40),
|
||||||
const SizedBox(height: 28),
|
const SizedBox(height: 28),
|
||||||
GamePanel(
|
GamePanel(
|
||||||
padding: const EdgeInsets.all(22),
|
padding: const EdgeInsets.all(22),
|
||||||
|
|||||||
@@ -19,12 +19,16 @@ class ShopApiProvider {
|
|||||||
required String kind,
|
required String kind,
|
||||||
required String productId,
|
required String productId,
|
||||||
required String token,
|
required String token,
|
||||||
|
String purchaseData = '',
|
||||||
|
String signature = '',
|
||||||
}) =>
|
}) =>
|
||||||
_api.post('/shop/purchase', body: {
|
_api.post('/shop/purchase', body: {
|
||||||
'store': store,
|
'store': store,
|
||||||
'kind': kind,
|
'kind': kind,
|
||||||
'product_id': productId,
|
'product_id': productId,
|
||||||
'token': token,
|
'token': token,
|
||||||
|
'purchase_data': purchaseData,
|
||||||
|
'signature': signature,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<Response> adReward(String token) =>
|
Future<Response> adReward(String token) =>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class ShopMapper {
|
|||||||
vipDays: (j['vip_days'] ?? 0) as int,
|
vipDays: (j['vip_days'] ?? 0) as int,
|
||||||
priceToman: (j['price_toman'] ?? 0) as int,
|
priceToman: (j['price_toman'] ?? 0) as int,
|
||||||
bonusPct: (j['bonus_pct'] ?? 0) as int,
|
bonusPct: (j['bonus_pct'] ?? 0) as int,
|
||||||
|
sku: (j['sku'] ?? '') as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
static TicketPackage ticket(Map<String, dynamic> j) => TicketPackage(
|
static TicketPackage ticket(Map<String, dynamic> j) => TicketPackage(
|
||||||
@@ -16,6 +17,7 @@ class ShopMapper {
|
|||||||
title: j['title'] as String,
|
title: j['title'] as String,
|
||||||
tickets: (j['tickets'] ?? 0) as int,
|
tickets: (j['tickets'] ?? 0) as int,
|
||||||
priceToman: (j['price_toman'] ?? 0) as int,
|
priceToman: (j['price_toman'] ?? 0) as int,
|
||||||
|
sku: (j['sku'] ?? '') as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
static CardSkin card(Map<String, dynamic> j) => CardSkin(
|
static CardSkin card(Map<String, dynamic> j) => CardSkin(
|
||||||
@@ -30,6 +32,7 @@ class ShopMapper {
|
|||||||
multiplier: (j['multiplier'] ?? 1) as int,
|
multiplier: (j['multiplier'] ?? 1) as int,
|
||||||
hours: (j['hours'] ?? 0) as int,
|
hours: (j['hours'] ?? 0) as int,
|
||||||
priceToman: (j['price_toman'] ?? 0) as int,
|
priceToman: (j['price_toman'] ?? 0) as int,
|
||||||
|
sku: (j['sku'] ?? '') as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
static VipPackage vip(Map<String, dynamic> j) => VipPackage(
|
static VipPackage vip(Map<String, dynamic> j) => VipPackage(
|
||||||
@@ -37,6 +40,7 @@ class ShopMapper {
|
|||||||
title: j['title'] as String,
|
title: j['title'] as String,
|
||||||
months: (j['months'] ?? 1) as int,
|
months: (j['months'] ?? 1) as int,
|
||||||
priceToman: (j['price_toman'] ?? 0) as int,
|
priceToman: (j['price_toman'] ?? 0) as int,
|
||||||
|
sku: (j['sku'] ?? '') as String,
|
||||||
);
|
);
|
||||||
|
|
||||||
static ShopData shopData(Map<String, dynamic> j) {
|
static ShopData shopData(Map<String, dynamic> j) {
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ class ShopRepositoryImpl extends ShopRepository {
|
|||||||
kind: params.kind,
|
kind: params.kind,
|
||||||
productId: params.productId,
|
productId: params.productId,
|
||||||
token: params.token,
|
token: params.token,
|
||||||
|
purchaseData: params.purchaseData,
|
||||||
|
signature: params.signature,
|
||||||
);
|
);
|
||||||
if (res.statusCode == 200) return const DataSuccess('خرید با موفقیت انجام شد');
|
if (res.statusCode == 200) return const DataSuccess('خرید با موفقیت انجام شد');
|
||||||
return DataError(errorConvertor(res.statusCode, _msg(res)));
|
return DataError(errorConvertor(res.statusCode, _msg(res)));
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class CoinPackage {
|
|||||||
final int vipDays;
|
final int vipDays;
|
||||||
final int priceToman;
|
final int priceToman;
|
||||||
final int bonusPct;
|
final int bonusPct;
|
||||||
|
final String sku; // شناسهی محصول در پنلِ فروشگاه (برای پرداختِ native)
|
||||||
const CoinPackage({
|
const CoinPackage({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.title,
|
required this.title,
|
||||||
@@ -13,6 +14,7 @@ class CoinPackage {
|
|||||||
required this.vipDays,
|
required this.vipDays,
|
||||||
required this.priceToman,
|
required this.priceToman,
|
||||||
required this.bonusPct,
|
required this.bonusPct,
|
||||||
|
this.sku = '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,11 +23,13 @@ class TicketPackage {
|
|||||||
final String title;
|
final String title;
|
||||||
final int tickets;
|
final int tickets;
|
||||||
final int priceToman;
|
final int priceToman;
|
||||||
|
final String sku;
|
||||||
const TicketPackage({
|
const TicketPackage({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.tickets,
|
required this.tickets,
|
||||||
required this.priceToman,
|
required this.priceToman,
|
||||||
|
this.sku = '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,12 +47,14 @@ class Booster {
|
|||||||
final int multiplier;
|
final int multiplier;
|
||||||
final int hours;
|
final int hours;
|
||||||
final int priceToman;
|
final int priceToman;
|
||||||
|
final String sku;
|
||||||
const Booster({
|
const Booster({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.multiplier,
|
required this.multiplier,
|
||||||
required this.hours,
|
required this.hours,
|
||||||
required this.priceToman,
|
required this.priceToman,
|
||||||
|
this.sku = '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,11 +63,13 @@ class VipPackage {
|
|||||||
final String title;
|
final String title;
|
||||||
final int months;
|
final int months;
|
||||||
final int priceToman;
|
final int priceToman;
|
||||||
|
final String sku;
|
||||||
const VipPackage({
|
const VipPackage({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.months,
|
required this.months,
|
||||||
required this.priceToman,
|
required this.priceToman,
|
||||||
|
this.sku = '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
import '../../../../core/payment/payment_gateway.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';
|
||||||
@@ -17,6 +18,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
final SelectCardUseCase selectCardUseCase;
|
final SelectCardUseCase selectCardUseCase;
|
||||||
final PurchaseUseCase purchaseUseCase;
|
final PurchaseUseCase purchaseUseCase;
|
||||||
final AdRewardUseCase adRewardUseCase;
|
final AdRewardUseCase adRewardUseCase;
|
||||||
|
final PaymentGateway gateway;
|
||||||
|
|
||||||
ShopBloc(
|
ShopBloc(
|
||||||
this.getShopUseCase,
|
this.getShopUseCase,
|
||||||
@@ -24,6 +26,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
this.selectCardUseCase,
|
this.selectCardUseCase,
|
||||||
this.purchaseUseCase,
|
this.purchaseUseCase,
|
||||||
this.adRewardUseCase,
|
this.adRewardUseCase,
|
||||||
|
this.gateway,
|
||||||
) : super(ShopBlocState.initial()) {
|
) : super(ShopBlocState.initial()) {
|
||||||
on<LoadShopEvent>((event, emit) => _load(emit));
|
on<LoadShopEvent>((event, emit) => _load(emit));
|
||||||
|
|
||||||
@@ -33,15 +36,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
on<SelectCardEvent>((event, emit) =>
|
on<SelectCardEvent>((event, emit) =>
|
||||||
_action(emit, () => selectCardUseCase(event.cardId)));
|
_action(emit, () => selectCardUseCase(event.cardId)));
|
||||||
|
|
||||||
on<PurchaseEvent>((event, emit) => _action(
|
on<PurchaseEvent>((event, emit) => _action(emit, () => _purchase(event)));
|
||||||
emit,
|
|
||||||
() => purchaseUseCase(PurchaseParams(
|
|
||||||
store: 'bazaar',
|
|
||||||
kind: event.kind,
|
|
||||||
productId: event.productId,
|
|
||||||
token:
|
|
||||||
'dev-${event.kind}-${event.productId}-${DateTime.now().millisecondsSinceEpoch}',
|
|
||||||
))));
|
|
||||||
|
|
||||||
on<AdRewardEvent>((event, emit) => _action(
|
on<AdRewardEvent>((event, emit) => _action(
|
||||||
emit,
|
emit,
|
||||||
@@ -56,6 +51,42 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// جریانِ خرید: ابتدا پرداختِ فروشگاهی (native) اجرا میشود، سپس مدرکِ خرید
|
||||||
|
/// (token/purchaseData/signature) برای اعتبارسنجی به بکاند فرستاده میشود و
|
||||||
|
/// در پایان، خرید در فروشگاه consume میشود.
|
||||||
|
Future<DataState<String>> _purchase(PurchaseEvent event) async {
|
||||||
|
// برای پرداختِ native به SKUِ فروشگاه نیاز است؛ اگر تنظیم نشده باشد از
|
||||||
|
// شناسهی کاتالوگ استفاده میکنیم (حالتِ توسعه/تکفروشگاهی).
|
||||||
|
final sku = event.sku.isNotEmpty ? event.sku : event.productId;
|
||||||
|
|
||||||
|
final PurchaseResult result;
|
||||||
|
try {
|
||||||
|
result = await gateway.purchase(sku);
|
||||||
|
} catch (e) {
|
||||||
|
return DataError<String>('خطا در پرداخت: $e');
|
||||||
|
}
|
||||||
|
if (!result.success) {
|
||||||
|
return DataError<String>('خرید انجام نشد یا لغو شد');
|
||||||
|
}
|
||||||
|
|
||||||
|
final verify = await purchaseUseCase(PurchaseParams(
|
||||||
|
store: gateway.store,
|
||||||
|
kind: event.kind,
|
||||||
|
productId: event.productId,
|
||||||
|
token: result.token,
|
||||||
|
purchaseData: result.purchaseData,
|
||||||
|
signature: result.signature,
|
||||||
|
));
|
||||||
|
|
||||||
|
// پس از تأییدِ بکاند، خرید را در فروشگاه نهایی/مصرف میکنیم.
|
||||||
|
if (verify is DataSuccess && result.onConfirmed != null) {
|
||||||
|
try {
|
||||||
|
await result.onConfirmed!();
|
||||||
|
} catch (_) {/* consume ناموفق حیاتی نیست */}
|
||||||
|
}
|
||||||
|
return verify;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _load(Emitter<ShopBlocState> emit) async {
|
Future<void> _load(Emitter<ShopBlocState> emit) async {
|
||||||
emit(state.copyWith(loadStatus: ShopLoading()));
|
emit(state.copyWith(loadStatus: ShopLoading()));
|
||||||
final res = await getShopUseCase(const NoParams());
|
final res = await getShopUseCase(const NoParams());
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ class SelectCardEvent extends ShopEvent {
|
|||||||
|
|
||||||
class PurchaseEvent extends ShopEvent {
|
class PurchaseEvent extends ShopEvent {
|
||||||
final String kind;
|
final String kind;
|
||||||
final String productId;
|
final String productId; // شناسهی کاتالوگ (برای اعتباردهی در بکاند)
|
||||||
PurchaseEvent(this.kind, this.productId);
|
final String sku; // شناسهی محصول در پنلِ فروشگاه (برای پرداختِ native)
|
||||||
|
PurchaseEvent(this.kind, this.productId, {this.sku = ''});
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdRewardEvent extends ShopEvent {}
|
class AdRewardEvent extends ShopEvent {}
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class _CoinsTab extends StatelessWidget {
|
|||||||
label: '${p.priceToman} تومان',
|
label: '${p.priceToman} تومان',
|
||||||
onTap:
|
onTap:
|
||||||
() =>
|
() =>
|
||||||
context.read<ShopBloc>().add(PurchaseEvent('coin', p.id)),
|
context.read<ShopBloc>().add(PurchaseEvent('coin', p.id, sku: p.sku)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -237,7 +237,7 @@ class _TicketsTab extends StatelessWidget {
|
|||||||
label: '${p.priceToman} تومان',
|
label: '${p.priceToman} تومان',
|
||||||
onTap:
|
onTap:
|
||||||
() => context.read<ShopBloc>().add(
|
() => context.read<ShopBloc>().add(
|
||||||
PurchaseEvent('ticket', p.id),
|
PurchaseEvent('ticket', p.id, sku: p.sku),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -264,7 +264,7 @@ class _BoostersTab extends StatelessWidget {
|
|||||||
label: '${b.priceToman} تومان',
|
label: '${b.priceToman} تومان',
|
||||||
onTap:
|
onTap:
|
||||||
() => context.read<ShopBloc>().add(
|
() => context.read<ShopBloc>().add(
|
||||||
PurchaseEvent('booster', b.id),
|
PurchaseEvent('booster', b.id, sku: b.sku),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -292,7 +292,7 @@ class _VipTab extends StatelessWidget {
|
|||||||
label: '${p.priceToman} تومان',
|
label: '${p.priceToman} تومان',
|
||||||
onTap:
|
onTap:
|
||||||
() =>
|
() =>
|
||||||
context.read<ShopBloc>().add(PurchaseEvent('vip', p.id)),
|
context.read<ShopBloc>().add(PurchaseEvent('vip', p.id, sku: p.sku)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class VipScreen extends StatelessWidget {
|
|||||||
busy: state.busy,
|
busy: state.busy,
|
||||||
onBuy: () => context
|
onBuy: () => context
|
||||||
.read<ShopBloc>()
|
.read<ShopBloc>()
|
||||||
.add(PurchaseEvent('vip', p.id)),
|
.add(PurchaseEvent('vip', p.id, sku: p.sku)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (packages.isEmpty)
|
if (packages.isEmpty)
|
||||||
|
|||||||
@@ -41,10 +41,12 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
final d = state.dailyStatus;
|
final d = state.dailyStatus;
|
||||||
if (d is DailySuccess) {
|
if (d is DailySuccess) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('سکه روزانه دریافت شد: +${d.amount}')));
|
SnackBar(content: Text('سکه روزانه دریافت شد: +${d.amount}')),
|
||||||
|
);
|
||||||
} else if (d is DailyError) {
|
} else if (d is DailyError) {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(
|
||||||
.showSnackBar(SnackBar(content: Text(d.message)));
|
context,
|
||||||
|
).showSnackBar(SnackBar(content: Text(d.message)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@@ -60,13 +62,16 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const GlowText('سلطان حکم', size: 44),
|
const GlowText('حاکم ایرانی', size: 44),
|
||||||
const SizedBox(height: 44),
|
const SizedBox(height: 44),
|
||||||
GameButton(
|
GameButton(
|
||||||
label: 'بازی',
|
label: 'بازی',
|
||||||
icon: Icons.style,
|
icon: Icons.style,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
colors: const [Color(0xFFC2185B), Color(0xFF6A0D38)],
|
colors: const [
|
||||||
|
Color(0xFFC2185B),
|
||||||
|
Color(0xFF6A0D38),
|
||||||
|
],
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await context.push('/game/tiers');
|
await context.push('/game/tiers');
|
||||||
if (context.mounted) _reload();
|
if (context.mounted) _reload();
|
||||||
@@ -77,7 +82,10 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
label: 'دورهمی',
|
label: 'دورهمی',
|
||||||
icon: Icons.group_add,
|
icon: Icons.group_add,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
colors: const [Color(0xFF1565C0), Color(0xFF0A2E57)],
|
colors: const [
|
||||||
|
Color(0xFF1565C0),
|
||||||
|
Color(0xFF0A2E57),
|
||||||
|
],
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await context.push('/private');
|
await context.push('/private');
|
||||||
if (context.mounted) _reload();
|
if (context.mounted) _reload();
|
||||||
@@ -88,7 +96,10 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
label: 'رتبهبندی',
|
label: 'رتبهبندی',
|
||||||
icon: Icons.leaderboard,
|
icon: Icons.leaderboard,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
colors: const [Color(0xFFE9952F), Color(0xFF9C5A00)],
|
colors: const [
|
||||||
|
Color(0xFFE9952F),
|
||||||
|
Color(0xFF9C5A00),
|
||||||
|
],
|
||||||
onTap: () => context.push('/leaderboard'),
|
onTap: () => context.push('/leaderboard'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -96,7 +107,10 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
label: 'فروشگاه',
|
label: 'فروشگاه',
|
||||||
icon: Icons.storefront,
|
icon: Icons.storefront,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
colors: const [Color(0xFF7B1FA2), Color(0xFF3E0A57)],
|
colors: const [
|
||||||
|
Color(0xFF7B1FA2),
|
||||||
|
Color(0xFF3E0A57),
|
||||||
|
],
|
||||||
onTap: () => _openShop(context),
|
onTap: () => _openShop(context),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
@@ -104,9 +118,14 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
label: 'سکه روزانه',
|
label: 'سکه روزانه',
|
||||||
icon: Icons.monetization_on,
|
icon: Icons.monetization_on,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
colors: const [AppColors.success, AppColors.successDark],
|
colors: const [
|
||||||
onTap: () =>
|
AppColors.success,
|
||||||
context.read<WalletBloc>().add(ClaimDailyEvent()),
|
AppColors.successDark,
|
||||||
|
],
|
||||||
|
onTap:
|
||||||
|
() => context.read<WalletBloc>().add(
|
||||||
|
ClaimDailyEvent(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -119,8 +138,10 @@ class _LobbyScreenState extends State<LobbyScreen> {
|
|||||||
context.go('/login');
|
context.go('/login');
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.logout, color: Colors.white54),
|
icon: const Icon(Icons.logout, color: Colors.white54),
|
||||||
label: const Text('خروج',
|
label: const Text(
|
||||||
style: TextStyle(color: Colors.white54)),
|
'خروج',
|
||||||
|
style: TextStyle(color: Colors.white54),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
@@ -176,7 +197,8 @@ class _TopBar extends StatelessWidget {
|
|||||||
color: AppColors.panel,
|
color: AppColors.panel,
|
||||||
border: Border.all(color: AppColors.gold, width: 2),
|
border: Border.all(color: AppColors.gold, width: 2),
|
||||||
),
|
),
|
||||||
child: (w == null || w.avatar.isEmpty)
|
child:
|
||||||
|
(w == null || w.avatar.isEmpty)
|
||||||
? const Icon(Icons.person, color: AppColors.gold)
|
? const Icon(Icons.person, color: AppColors.gold)
|
||||||
: ClipOval(child: RandomAvatar(w.avatar)),
|
: ClipOval(child: RandomAvatar(w.avatar)),
|
||||||
),
|
),
|
||||||
@@ -186,23 +208,35 @@ class _TopBar extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Row(children: [
|
Row(
|
||||||
|
children: [
|
||||||
if (w != null && w.name.isNotEmpty) ...[
|
if (w != null && w.name.isNotEmpty) ...[
|
||||||
Text(w.name,
|
Text(
|
||||||
|
w.name,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white, fontWeight: FontWeight.bold)),
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
],
|
],
|
||||||
if (w?.vip == true) const _VipTag(),
|
if (w?.vip == true) const _VipTag(),
|
||||||
]),
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Row(children: [
|
Row(
|
||||||
|
children: [
|
||||||
const Icon(Icons.star, color: AppColors.gold, size: 16),
|
const Icon(Icons.star, color: AppColors.gold, size: 16),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text('سطح ${w?.level ?? '-'}',
|
Text(
|
||||||
|
'سطح ${w?.level ?? '-'}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.gold, fontWeight: FontWeight.bold)),
|
color: AppColors.gold,
|
||||||
]),
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
@@ -210,7 +244,8 @@ class _TopBar extends StatelessWidget {
|
|||||||
width: 96,
|
width: 96,
|
||||||
height: 7,
|
height: 7,
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
value: (w == null || w.xpForNext == 0)
|
value:
|
||||||
|
(w == null || w.xpForNext == 0)
|
||||||
? 0
|
? 0
|
||||||
: w.xpIntoLevel / w.xpForNext,
|
: w.xpIntoLevel / w.xpForNext,
|
||||||
backgroundColor: Colors.white10,
|
backgroundColor: Colors.white10,
|
||||||
@@ -224,13 +259,17 @@ class _TopBar extends StatelessWidget {
|
|||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: onCoinTap,
|
onTap: onCoinTap,
|
||||||
child: StatChip(
|
child: StatChip(
|
||||||
icon: Icons.confirmation_number, value: '${w?.tickets ?? 0}'),
|
icon: Icons.confirmation_number,
|
||||||
|
value: '${w?.tickets ?? 0}',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: onCoinTap,
|
onTap: onCoinTap,
|
||||||
child: StatChip(
|
child: StatChip(
|
||||||
icon: Icons.monetization_on, value: '${w?.coins ?? 0}'),
|
icon: Icons.monetization_on,
|
||||||
|
value: '${w?.coins ?? 0}',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -246,14 +285,18 @@ class _VipTag extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
colors: [Color(0xFFFFD54F), AppColors.goldDark]),
|
colors: [Color(0xFFFFD54F), AppColors.goldDark],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: const Text('VIP',
|
child: const Text(
|
||||||
|
'VIP',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.bg,
|
color: AppColors.bg,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 10)),
|
fontSize: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,6 +222,14 @@ packages:
|
|||||||
url: "https://pub.myket.ir"
|
url: "https://pub.myket.ir"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_poolakey:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_poolakey
|
||||||
|
sha256: "141415a62f0b88465dc1ec852c641a373de34afb193613c2583835457801f185"
|
||||||
|
url: "https://pub.myket.ir"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0+1.0.0"
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -392,6 +400,14 @@ packages:
|
|||||||
url: "https://pub.myket.ir"
|
url: "https://pub.myket.ir"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
|
myket_iap:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: myket_iap
|
||||||
|
sha256: "26e12cf257771e2bc0eef6af1ca45e926401d43124899c0118542b2bb6d31331"
|
||||||
|
url: "https://pub.myket.ir"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.12"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ dependencies:
|
|||||||
flame: ^1.30.1
|
flame: ^1.30.1
|
||||||
flame_audio: ^2.11.14
|
flame_audio: ^2.11.14
|
||||||
random_avatar: ^0.0.8
|
random_avatar: ^0.0.8
|
||||||
|
# خرید درونبرنامهای: هر flavor یکی را استفاده میکند (مایکت/کافهبازار).
|
||||||
|
myket_iap: ^1.1.11
|
||||||
|
flutter_poolakey: ^2.2.0
|
||||||
|
|
||||||
# path_provider_android نسخهی 2.3.x به jni (کد native + NDK) وابسته شد و build را
|
# path_provider_android نسخهی 2.3.x به jni (کد native + NDK) وابسته شد و build را
|
||||||
# سنگین/کند میکند. تا نسخهی پیشاز‑jni پین میکنیم تا NDK لازم نباشد.
|
# سنگین/کند میکند. تا نسخهی پیشاز‑jni پین میکنیم تا NDK لازم نباشد.
|
||||||
|
|||||||