mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 08:50:40 +00:00
f0d707b071
* Upgraded `targetSdkVersion` to 34
* added price to `IAPProduct`
* implemented `ProFeaturesScreen` (wip)
* finalized `ProFeaturesScreen` layout
* replaced `ProFeaturesDialog` with `ProFeaturesScreen`
* added translations
* fixed feature checkbox width calculation
* fixed tests
* separated android & ios features
* NPE
* changed "get pro" tile colors
* unified Lightmeter Pro related naming
* typo
* updated golden tests
* use iap 0.11.0
* revert unrelated changes
This reverts commit bae5ead8f0
.
* lint
* adjusted eng translation
* updated goldens
128 lines
4 KiB
Dart
128 lines
4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:light_sensor/light_sensor.dart';
|
|
import 'package:lightmeter/application_wrapper.dart';
|
|
import 'package:lightmeter/data/models/supported_locale.dart';
|
|
import 'package:lightmeter/environment.dart';
|
|
import 'package:lightmeter/generated/l10n.dart';
|
|
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
|
import 'package:lightmeter/res/theme.dart';
|
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
|
|
|
import '../integration_test/mocks/paid_features_mock.dart';
|
|
import '../integration_test/utils/platform_channel_mock.dart';
|
|
|
|
/// Provides [MaterialApp] with default theme and "en" localization
|
|
class WidgetTestApplicationMock extends StatelessWidget {
|
|
final Widget child;
|
|
|
|
const WidgetTestApplicationMock({
|
|
required this.child,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
theme: themeFrom(primaryColorsList[5], Brightness.light),
|
|
locale: const Locale('en'),
|
|
localizationsDelegates: const [
|
|
S.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: S.delegate.supportedLocales,
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
|
child: child!,
|
|
),
|
|
home: Scaffold(body: child),
|
|
);
|
|
}
|
|
}
|
|
|
|
class GoldenTestApplicationMock extends StatefulWidget {
|
|
final IAPProductStatus productStatus;
|
|
final Widget child;
|
|
|
|
const GoldenTestApplicationMock({
|
|
this.productStatus = IAPProductStatus.purchased,
|
|
required this.child,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
State<GoldenTestApplicationMock> createState() => _GoldenTestApplicationMockState();
|
|
}
|
|
|
|
class _GoldenTestApplicationMockState extends State<GoldenTestApplicationMock> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
LightSensor.methodChannel,
|
|
(methodCall) async {
|
|
switch (methodCall.method) {
|
|
case "sensor":
|
|
return true;
|
|
default:
|
|
return null;
|
|
}
|
|
},
|
|
);
|
|
setupLightSensorStreamHandler();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
LightSensor.methodChannel,
|
|
null,
|
|
);
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IAPProducts(
|
|
products: [
|
|
IAPProduct(
|
|
storeId: IAPProductType.paidFeatures.storeId,
|
|
status: widget.productStatus,
|
|
price: '0.0\$',
|
|
),
|
|
],
|
|
child: ApplicationWrapper(
|
|
const Environment.dev(),
|
|
child: MockIAPProviders(
|
|
equipmentProfiles: mockEquipmentProfiles,
|
|
selectedEquipmentProfileId: mockEquipmentProfiles.first.id,
|
|
selectedFilm: mockFilms.first,
|
|
child: Builder(
|
|
builder: (context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
theme: UserPreferencesProvider.themeOf(context),
|
|
locale: Locale(UserPreferencesProvider.localeOf(context).intlName),
|
|
localizationsDelegates: const [
|
|
S.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: S.delegate.supportedLocales,
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
|
|
child: child!,
|
|
),
|
|
home: widget.child,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|