mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 17:00:39 +00:00
Compare commits
3 commits
3bb3f12641
...
ddc7ec8c8b
Author | SHA1 | Date | |
---|---|---|---|
|
ddc7ec8c8b | ||
|
434327a7d0 | ||
|
068834bfe5 |
5 changed files with 22 additions and 9 deletions
|
@ -24,7 +24,6 @@ class RemoteConfigService {
|
|||
await remoteConfig.setDefaults(featuresDefaultValues.map((key, value) => MapEntry(key.name, value)));
|
||||
await remoteConfig.activate();
|
||||
await remoteConfig.ensureInitialized();
|
||||
unawaited(remoteConfig.fetch());
|
||||
|
||||
log('Firebase remote config initialized successfully');
|
||||
} on FirebaseException catch (e) {
|
||||
|
@ -34,6 +33,12 @@ class RemoteConfigService {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> fetchConfig() async {
|
||||
// https://github.com/firebase/flutterfire/issues/6196#issuecomment-927751667
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
await FirebaseRemoteConfig.instance.fetch();
|
||||
}
|
||||
|
||||
dynamic getValue(Feature feature) => FirebaseRemoteConfig.instance.getValue(feature.name).toValue(feature);
|
||||
|
||||
Map<Feature, dynamic> getAll() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/data/models/feature.dart';
|
||||
|
@ -25,7 +26,11 @@ class RemoteConfigProviderState extends State<RemoteConfigProvider> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen(_updateFeatures);
|
||||
widget.remoteConfigService.fetchConfig();
|
||||
_updatesSubscription = widget.remoteConfigService.onConfigUpdated().listen(
|
||||
_updateFeatures,
|
||||
onError: (e) => log(e.toString()),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -18,12 +18,14 @@ class BuyProListTile extends StatelessWidget {
|
|||
return ListTile(
|
||||
leading: const Icon(Icons.star),
|
||||
title: Text(unlockFeaturesEnabled ? S.of(context).unlockProFeatures : S.of(context).buyLightmeterPro),
|
||||
onTap: () {
|
||||
showBuyProDialog(context);
|
||||
ServicesProvider.of(context)
|
||||
.analytics
|
||||
.logUnlockProFeatures(unlockFeaturesEnabled ? 'Unlock Pro features' : 'Buy Lightmeter Pro');
|
||||
},
|
||||
onTap: !isPending
|
||||
? () {
|
||||
showBuyProDialog(context);
|
||||
ServicesProvider.of(context)
|
||||
.analytics
|
||||
.logUnlockProFeatures(unlockFeaturesEnabled ? 'Unlock Pro features' : 'Buy Lightmeter Pro');
|
||||
}
|
||||
: null,
|
||||
trailing: isPending
|
||||
? const SizedBox(
|
||||
height: Dimens.grid24,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
name: lightmeter
|
||||
description: Lightmeter app inspired by Material 3 design system.
|
||||
publish_to: "none"
|
||||
version: 0.15.2+43
|
||||
version: 0.15.3+44
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
|
|
@ -18,6 +18,7 @@ void main() {
|
|||
});
|
||||
|
||||
setUp(() {
|
||||
when(() => mockRemoteConfigService.fetchConfig()).thenAnswer((_) async {});
|
||||
when(() => mockRemoteConfigService.getValue(Feature.unlockProFeaturesText)).thenReturn(false);
|
||||
when(() => mockRemoteConfigService.getAll()).thenReturn({Feature.unlockProFeaturesText: false});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue