h-1.flutter.0/lib/config/app_config.dart
2026-03-05 09:33:38 +09:00

58 lines
3.3 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.

/// アプリ全体のバージョンと機能フラグを集中管理する設定クラス。
/// - バージョンや機能フラグは --dart-define で上書き可能。
/// - プレイストア公開やベータ配信時の切り替えを容易にする。
class AppConfig {
/// アプリのバージョン(ビルド時に --dart-define=APP_VERSION=... で上書き可能)。
static const String version = String.fromEnvironment('APP_VERSION', defaultValue: '1.0.0');
/// 機能フラグ(ビルド時に --dart-define で上書き可能)。
static const bool _enableDebugFeatures = bool.fromEnvironment('ENABLE_DEBUG_FEATURES', defaultValue: false);
static const bool _enableBillingDocsFlag = bool.fromEnvironment('ENABLE_BILLING_DOCS', defaultValue: true);
static const bool _enableSalesManagementFlag = bool.fromEnvironment('ENABLE_SALES_MANAGEMENT', defaultValue: false);
static const bool _enableSalesOperationsFlag = bool.fromEnvironment('ENABLE_SALES_OPERATIONS', defaultValue: false);
static const bool _enablePurchaseManagementFlag = bool.fromEnvironment('ENABLE_PURCHASE_MANAGEMENT', defaultValue: false);
static const bool _enableDebugWebhookLoggingFlag = bool.fromEnvironment('ENABLE_DEBUG_WEBHOOK', defaultValue: false);
static const String debugWebhookUrl = String.fromEnvironment(
'DEBUG_WEBHOOK_URL',
defaultValue: 'https://mm.ka.sugeee.com/hooks/x6nxx8q35jdkuetbmh89ogt5ze',
);
static bool get enableBillingDocs => _enableDebugFeatures || _enableBillingDocsFlag;
static bool get enableSalesManagement => _enableDebugFeatures || _enableSalesManagementFlag;
static bool get enableSalesOperations => _enableDebugFeatures || _enableSalesOperationsFlag;
static bool get enablePurchaseManagement => _enableDebugFeatures || _enablePurchaseManagementFlag;
static bool get enableDebugWebhookLogging => _enableDebugFeatures || _enableDebugWebhookLoggingFlag;
/// APIエンドポイント必要に応じて dart-define で注入)。
static const String apiEndpoint = String.fromEnvironment('API_ENDPOINT', defaultValue: '');
/// 機能フラグの一覧UIなどで表示する用途向け
static Map<String, bool> get features => {
'enableBillingDocs': enableBillingDocs,
'enableSalesManagement': enableSalesManagement,
'enableSalesOperations': enableSalesOperations,
'enablePurchaseManagement': enablePurchaseManagement,
'enableDebugWebhookLogging': enableDebugWebhookLogging,
};
/// 機能キーで有効/無効を判定するヘルパー。
static bool isFeatureEnabled(String key) => features[key] ?? false;
/// 有効なダッシュボードルート一覧(動的に増える場合はここで管理)。
static Set<String> get enabledRoutes {
final routes = <String>{'settings', 'dashboard'};
if (enableBillingDocs) {
routes.addAll({'invoice_history', 'invoice_input', 'master_hub', 'customer_master', 'product_master'});
}
if (enableSalesManagement) {
routes.addAll({'sales_management', 'sales_entries'});
}
if (enableSalesOperations) {
routes.addAll({'sales_orders', 'shipments', 'inventory', 'receivables'});
}
if (enablePurchaseManagement) {
routes.addAll({'purchase_entries', 'purchase_receipts'});
}
return routes;
}
}