[mob] Service locator for billingService
This commit is contained in:
@@ -22,7 +22,6 @@ import 'package:photos/events/user_logged_out_event.dart';
|
||||
import 'package:photos/models/key_attributes.dart';
|
||||
import 'package:photos/models/key_gen_result.dart';
|
||||
import 'package:photos/models/private_key_attributes.dart';
|
||||
import 'package:photos/services/billing_service.dart';
|
||||
import 'package:photos/services/collections_service.dart';
|
||||
import 'package:photos/services/favorites_service.dart';
|
||||
import "package:photos/services/home_widget_service.dart";
|
||||
@@ -216,7 +215,6 @@ class Configuration {
|
||||
CollectionsService.instance.clearCache();
|
||||
FavoritesService.instance.clearCache();
|
||||
MemoriesService.instance.clearCache();
|
||||
BillingService.instance.clearCache();
|
||||
SearchService.instance.clearCache();
|
||||
unawaited(HomeWidgetService.instance.clearHomeWidget());
|
||||
Bus.instance.fire(UserLoggedOutEvent());
|
||||
|
||||
@@ -28,7 +28,6 @@ import "package:photos/extensions/stop_watch.dart";
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/app_lifecycle_service.dart';
|
||||
import 'package:photos/services/billing_service.dart';
|
||||
import 'package:photos/services/collections_service.dart';
|
||||
import 'package:photos/services/favorites_service.dart';
|
||||
import "package:photos/services/filedata/filedata_service.dart";
|
||||
@@ -242,10 +241,6 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
||||
await UserService.instance.init();
|
||||
_logger.info("UserService init done $tlog");
|
||||
|
||||
_logger.info("BillingService init $tlog");
|
||||
BillingService.instance.init();
|
||||
_logger.info("BillingService init done $tlog");
|
||||
|
||||
_logger.info("CollectionsService init $tlog");
|
||||
await CollectionsService.instance.init(preferences);
|
||||
_logger.info("CollectionsService init done $tlog");
|
||||
|
||||
@@ -4,6 +4,7 @@ import "package:ente_cast_normal/ente_cast_normal.dart";
|
||||
import "package:ente_feature_flag/ente_feature_flag.dart";
|
||||
import "package:package_info_plus/package_info_plus.dart";
|
||||
import "package:photos/gateways/entity_gw.dart";
|
||||
import "package:photos/services/billing_service.dart";
|
||||
import "package:photos/services/entity_service.dart";
|
||||
import "package:photos/services/location_service.dart";
|
||||
import "package:photos/services/magic_cache_service.dart";
|
||||
@@ -114,3 +115,11 @@ MagicCacheService get magicCacheService {
|
||||
);
|
||||
return _magicCacheService!;
|
||||
}
|
||||
|
||||
BillingService? _billingService;
|
||||
BillingService get billingService {
|
||||
_billingService ??= BillingService(
|
||||
ServiceLocator.instance.enteDio,
|
||||
);
|
||||
return _billingService!;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:photos/core/errors.dart';
|
||||
import 'package:photos/core/network/network.dart';
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import 'package:photos/models/billing_plan.dart';
|
||||
import 'package:photos/models/subscription.dart';
|
||||
@@ -32,16 +31,16 @@ const kFamilyPlanManagementUrl = String.fromEnvironment(
|
||||
);
|
||||
|
||||
class BillingService {
|
||||
BillingService._privateConstructor();
|
||||
|
||||
static final BillingService instance = BillingService._privateConstructor();
|
||||
|
||||
final _logger = Logger("BillingService");
|
||||
final _enteDio = NetworkClient.instance.enteDio;
|
||||
late final _logger = Logger("BillingService");
|
||||
final Dio _enteDio;
|
||||
|
||||
bool _isOnSubscriptionPage = false;
|
||||
|
||||
Future<BillingPlans>? _future;
|
||||
BillingService(this._enteDio) {
|
||||
_logger.finest("BillingService constructor");
|
||||
init();
|
||||
}
|
||||
|
||||
void init() {
|
||||
// if (Platform.isIOS && kDebugMode) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import "package:photos/core/constants.dart";
|
||||
import 'package:photos/ente_theme_data.dart';
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import 'package:photos/models/subscription.dart';
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/billing_service.dart';
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import 'package:photos/ui/common/loading_widget.dart';
|
||||
@@ -29,7 +30,7 @@ class PaymentWebPage extends StatefulWidget {
|
||||
class _PaymentWebPageState extends State<PaymentWebPage> {
|
||||
final _logger = Logger("PaymentWebPageState");
|
||||
final UserService userService = UserService.instance;
|
||||
final BillingService billingService = BillingService.instance;
|
||||
late final BillingService billService = billingService;
|
||||
final String basePaymentUrl = kWebPaymentBaseEndpoint;
|
||||
InAppWebViewController? webView;
|
||||
double progress = 0;
|
||||
@@ -229,7 +230,7 @@ class _PaymentWebPageState extends State<PaymentWebPage> {
|
||||
final checkoutSessionID = queryParams['session_id'] ?? '';
|
||||
try {
|
||||
// ignore: unused_local_variable
|
||||
final response = await billingService.verifySubscription(
|
||||
final response = await billService.verifySubscription(
|
||||
widget.planId,
|
||||
checkoutSessionID,
|
||||
paymentProvider: stripe,
|
||||
|
||||
@@ -12,7 +12,7 @@ import "package:photos/generated/l10n.dart";
|
||||
import 'package:photos/models/billing_plan.dart';
|
||||
import 'package:photos/models/subscription.dart';
|
||||
import 'package:photos/models/user_details.dart';
|
||||
import 'package:photos/services/billing_service.dart';
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import "package:photos/theme/colors.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
@@ -46,7 +46,7 @@ class StoreSubscriptionPage extends StatefulWidget {
|
||||
|
||||
class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
||||
final _logger = Logger("SubscriptionPage");
|
||||
final _billingService = BillingService.instance;
|
||||
late final _billingService = billingService;
|
||||
final _userService = UserService.instance;
|
||||
Subscription? _currentSubscription;
|
||||
late StreamSubscription _purchaseUpdateSubscription;
|
||||
@@ -445,7 +445,7 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
||||
(route) => false,
|
||||
);
|
||||
unawaited(
|
||||
BillingService.instance.verifySubscription(
|
||||
_billingService.verifySubscription(
|
||||
freeProductID,
|
||||
"",
|
||||
paymentProvider: "ente",
|
||||
@@ -501,7 +501,7 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
||||
(route) => false,
|
||||
);
|
||||
unawaited(
|
||||
BillingService.instance.verifySubscription(
|
||||
_billingService.verifySubscription(
|
||||
freeProductID,
|
||||
"",
|
||||
paymentProvider: "ente",
|
||||
@@ -625,7 +625,7 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
|
||||
(route) => false,
|
||||
);
|
||||
unawaited(
|
||||
BillingService.instance.verifySubscription(
|
||||
_billingService.verifySubscription(
|
||||
freeProductID,
|
||||
"",
|
||||
paymentProvider: "ente",
|
||||
|
||||
@@ -9,7 +9,7 @@ import "package:photos/generated/l10n.dart";
|
||||
import 'package:photos/models/billing_plan.dart';
|
||||
import 'package:photos/models/subscription.dart';
|
||||
import 'package:photos/models/user_details.dart';
|
||||
import 'package:photos/services/billing_service.dart';
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import "package:photos/theme/colors.dart";
|
||||
import 'package:photos/theme/ente_theme.dart';
|
||||
@@ -46,7 +46,7 @@ class StripeSubscriptionPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
||||
final _billingService = BillingService.instance;
|
||||
late final _billingService = billingService;
|
||||
final _userService = UserService.instance;
|
||||
Subscription? _currentSubscription;
|
||||
late ProgressDialog _dialog;
|
||||
@@ -484,7 +484,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
||||
(route) => false,
|
||||
);
|
||||
unawaited(
|
||||
BillingService.instance.verifySubscription(
|
||||
_billingService.verifySubscription(
|
||||
freeProductID,
|
||||
"",
|
||||
paymentProvider: "ente",
|
||||
@@ -609,7 +609,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
|
||||
(route) => false,
|
||||
);
|
||||
unawaited(
|
||||
BillingService.instance.verifySubscription(
|
||||
_billingService.verifySubscription(
|
||||
freeProductID,
|
||||
"",
|
||||
paymentProvider: "ente",
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import "package:photos/app.dart";
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import 'package:photos/services/billing_service.dart';
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import 'package:photos/theme/ente_theme.dart';
|
||||
import "package:photos/ui/components/captioned_text_widget.dart";
|
||||
@@ -118,7 +118,7 @@ class GeneralSectionWidget extends StatelessWidget {
|
||||
final userDetails =
|
||||
await UserService.instance.getUserDetailsV2(memoryCount: false);
|
||||
// ignore: unawaited_futures
|
||||
BillingService.instance.launchFamilyPortal(context, userDetails);
|
||||
billingService.launchFamilyPortal(context, userDetails);
|
||||
}
|
||||
|
||||
void _onNotificationsTapped(BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user