mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
Merge branch 'main' of https://github.com/vodemn/m3_lightmeter into feature/ML-104
This commit is contained in:
commit
5a62326037
16 changed files with 218 additions and 125 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -60,3 +60,4 @@ ios/Runner/GoogleService-Info.plist
|
|||
/lib/firebase_options.dart
|
||||
|
||||
coverage/
|
||||
screenshots/
|
BIN
assets/camera_stub_image.jpg
Normal file
BIN
assets/camera_stub_image.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 899 KiB |
|
@ -6,8 +6,26 @@ enum IAPProductStatus {
|
|||
|
||||
enum IAPProductType { paidFeatures }
|
||||
|
||||
abstract class IAPProduct {
|
||||
const IAPProduct._();
|
||||
class IAPProduct {
|
||||
final String storeId;
|
||||
final IAPProductStatus status;
|
||||
|
||||
IAPProductStatus get status => IAPProductStatus.purchasable;
|
||||
const IAPProduct({
|
||||
required this.storeId,
|
||||
this.status = IAPProductStatus.purchasable,
|
||||
});
|
||||
|
||||
IAPProduct copyWith({IAPProductStatus? status}) => IAPProduct(
|
||||
storeId: storeId,
|
||||
status: status ?? this.status,
|
||||
);
|
||||
}
|
||||
|
||||
extension IAPProductTypeExtension on IAPProductType {
|
||||
String get storeId {
|
||||
switch (this) {
|
||||
case IAPProductType.paidFeatures:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,12 @@ class IAPProductsProviderState extends State<IAPProductsProvider> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IAPProducts(
|
||||
products: const [],
|
||||
products: [
|
||||
IAPProduct(
|
||||
storeId: IAPProductType.paidFeatures.storeId,
|
||||
status: IAPProductStatus.purchased,
|
||||
)
|
||||
],
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
|
@ -35,13 +40,28 @@ class IAPProducts extends InheritedModel<IAPProductType> {
|
|||
super.key,
|
||||
});
|
||||
|
||||
static IAPProduct? productOf(BuildContext context, IAPProductType type) => null;
|
||||
static IAPProduct? productOf(BuildContext context, IAPProductType type) {
|
||||
final IAPProducts? result = InheritedModel.inheritFrom<IAPProducts>(context, aspect: type);
|
||||
return result!._findProduct(type);
|
||||
}
|
||||
|
||||
static bool isPurchased(BuildContext context, IAPProductType type) => false;
|
||||
static bool isPurchased(BuildContext context, IAPProductType type) {
|
||||
final IAPProducts? result = InheritedModel.inheritFrom<IAPProducts>(context, aspect: type);
|
||||
return result!._findProduct(type)?.status == IAPProductStatus.purchased;
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(IAPProducts oldWidget) => false;
|
||||
|
||||
@override
|
||||
bool updateShouldNotifyDependent(covariant IAPProducts oldWidget, Set<IAPProductType> dependencies) => false;
|
||||
bool updateShouldNotifyDependent(IAPProducts oldWidget, Set<IAPProductType> dependencies) =>
|
||||
false;
|
||||
|
||||
IAPProduct? _findProduct(IAPProductType type) {
|
||||
try {
|
||||
return products.firstWhere((element) => element.storeId == type.storeId);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
integration_test/generate_screenshots.sh
Normal file
10
integration_test/generate_screenshots.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
flutter drive \
|
||||
--dart-define="cameraPreviewAspectRatio=240/320" \
|
||||
--dart-define="cameraStubImage=assets/camera_stub_image.jpg" \
|
||||
--driver=test_driver/screenshot_driver.dart \
|
||||
--target=integration_test/generate_screenshots.dart \
|
||||
--profile \
|
||||
--flavor=dev \
|
||||
--no-dds \
|
||||
--endless-trace-buffer \
|
||||
--purge-persistent-cache
|
|
@ -1,60 +1,24 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:lightmeter/data/caffeine_service.dart';
|
||||
import 'package:lightmeter/data/haptics_service.dart';
|
||||
import 'package:lightmeter/data/light_sensor_service.dart';
|
||||
import 'package:lightmeter/data/models/supported_locale.dart';
|
||||
import 'package:lightmeter/data/permissions_service.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/data/volume_events_service.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:lightmeter/providers/services_provider.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
import 'package:lightmeter/screens/metering/flow_metering.dart';
|
||||
import 'package:lightmeter/screens/settings/flow_settings.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class Application extends StatelessWidget {
|
||||
final Environment env;
|
||||
|
||||
const Application(this.env, {super.key});
|
||||
const Application({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: Future.wait([
|
||||
SharedPreferences.getInstance(),
|
||||
const LightSensorService(LocalPlatform()).hasSensor(),
|
||||
]),
|
||||
builder: (_, snapshot) {
|
||||
if (snapshot.data != null) {
|
||||
return IAPProviders(
|
||||
sharedPreferences: snapshot.data![0] as SharedPreferences,
|
||||
child: ServicesProvider(
|
||||
caffeineService: const CaffeineService(),
|
||||
environment: env.copyWith(hasLightSensor: snapshot.data![1] as bool),
|
||||
hapticsService: const HapticsService(),
|
||||
lightSensorService: const LightSensorService(LocalPlatform()),
|
||||
permissionsService: const PermissionsService(),
|
||||
userPreferencesService:
|
||||
UserPreferencesService(snapshot.data![0] as SharedPreferences),
|
||||
volumeEventsService: const VolumeEventsService(LocalPlatform()),
|
||||
child: UserPreferencesProvider(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final theme = UserPreferencesProvider.themeOf(context);
|
||||
final systemIconsBrightness =
|
||||
ThemeData.estimateBrightnessForColor(theme.colorScheme.onSurface);
|
||||
final systemIconsBrightness = ThemeData.estimateBrightnessForColor(theme.colorScheme.onSurface);
|
||||
return AnnotatedRegion(
|
||||
value: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarBrightness: systemIconsBrightness == Brightness.light
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
statusBarBrightness:
|
||||
systemIconsBrightness == Brightness.light ? Brightness.dark : Brightness.light,
|
||||
statusBarIconBrightness: systemIconsBrightness,
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
systemNavigationBarIconBrightness: systemIconsBrightness,
|
||||
|
@ -80,19 +44,6 @@ class Application extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.error != null) {
|
||||
return Center(child: Text(snapshot.error!.toString()));
|
||||
}
|
||||
|
||||
// TODO(@vodemn): maybe user splashscreen instead
|
||||
return const SizedBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
55
lib/application_wrapper.dart
Normal file
55
lib/application_wrapper.dart
Normal file
|
@ -0,0 +1,55 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/data/caffeine_service.dart';
|
||||
import 'package:lightmeter/data/haptics_service.dart';
|
||||
import 'package:lightmeter/data/light_sensor_service.dart';
|
||||
import 'package:lightmeter/data/permissions_service.dart';
|
||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||
import 'package:lightmeter/data/volume_events_service.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/providers/services_provider.dart';
|
||||
import 'package:lightmeter/providers/user_preferences_provider.dart';
|
||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class ApplicationWrapper extends StatelessWidget {
|
||||
final Environment env;
|
||||
final Widget child;
|
||||
|
||||
const ApplicationWrapper(this.env, {required this.child, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: Future.wait([
|
||||
SharedPreferences.getInstance(),
|
||||
const LightSensorService(LocalPlatform()).hasSensor(),
|
||||
]),
|
||||
builder: (_, snapshot) {
|
||||
if (snapshot.data != null) {
|
||||
return IAPProviders(
|
||||
sharedPreferences: snapshot.data![0] as SharedPreferences,
|
||||
child: ServicesProvider(
|
||||
caffeineService: const CaffeineService(),
|
||||
environment: env.copyWith(hasLightSensor: snapshot.data![1] as bool),
|
||||
hapticsService: const HapticsService(),
|
||||
lightSensorService: const LightSensorService(LocalPlatform()),
|
||||
permissionsService: const PermissionsService(),
|
||||
userPreferencesService:
|
||||
UserPreferencesService(snapshot.data![0] as SharedPreferences),
|
||||
volumeEventsService: const VolumeEventsService(LocalPlatform()),
|
||||
child: UserPreferencesProvider(
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.error != null) {
|
||||
return Center(child: Text(snapshot.error!.toString()));
|
||||
}
|
||||
|
||||
// TODO(@vodemn): maybe user splashscreen instead
|
||||
return const SizedBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@
|
|||
"film": "胶片",
|
||||
"filmPush": "胶片 (push)",
|
||||
"filmPull": "胶片 (pull)",
|
||||
"filmReciprocityHint": "Applies correction for shutter speeds grater than 1 second",
|
||||
"filmReciprocityHint": "对快门速度超过 1 秒的情况进行修正",
|
||||
"equipmentProfileName": "设备配置名称",
|
||||
"equipmentProfileNameHint": "Praktica MTL5B",
|
||||
"equipmentProfileAllValues": "全部",
|
||||
|
@ -54,12 +54,12 @@
|
|||
"shutterSpeedValues": "快门速度",
|
||||
"shutterSpeedValuesFilterDescription": "选择要显示的快门速度范围。这通常由您使用的相机机身决定。",
|
||||
"isoValues": "ISO",
|
||||
"isoValuesFilterDescription": "选择要显示的 ISO。这些值可能是您最常用的值,也可能是相机支持的值。",
|
||||
"isoValuesFilterDescription": "选择要显示的 ISO 。这些值可能是您最常用的值,也可能是相机支持的值。",
|
||||
"equipmentProfile": "设备配置",
|
||||
"equipmentProfiles": "设备配置",
|
||||
"tapToAdd": "點擊添加",
|
||||
"filmsInUse": "Films in use",
|
||||
"filmsInUseDescription": "Select films which you use.",
|
||||
"filmsInUse": "使用的胶片",
|
||||
"filmsInUseDescription": "选择你使用的胶片",
|
||||
"general": "通用",
|
||||
"keepScreenOn": "保持屏幕常亮",
|
||||
"haptics": "震动",
|
||||
|
@ -92,20 +92,20 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"buyLightmeterPro": "Buy Lightmeter Pro",
|
||||
"buyLightmeterPro": "购买 Lightmeter Pro",
|
||||
"lightmeterPro": "Lightmeter Pro",
|
||||
"lightmeterProDescription": "Unlocks extra features, such as equipment profiles containing filters for aperture, shutter speed, and more; and a list of films with compensation for what's known as reciprocity failure.\n\nThe source code of Lightmeter is available on GitHub. You are welcome to compile it yourself. However, if you want to support the development and receive new features and updates, consider purchasing Lightmeter Pro.",
|
||||
"buy": "Buy",
|
||||
"tooltipAdd": "Add",
|
||||
"tooltipClose": "Close",
|
||||
"tooltipExpand": "Expand",
|
||||
"tooltipCollapse": "Collapse",
|
||||
"tooltipCopy": "Copy",
|
||||
"tooltipDelete": "Delete",
|
||||
"tooltipSelectAll": "Select all",
|
||||
"tooltipDesecelectAll": "Deselect all",
|
||||
"resetToZero": "Reset to zero",
|
||||
"tooltipUseLightSensor": "Use lightsensor",
|
||||
"tooltipUseCamera": "Use camera",
|
||||
"tooltipOpenSettings": "Open settings"
|
||||
"lightmeterProDescription": "购买以解锁额外功能。例如包含光圈、快门速度等参数的配置文件;以及一个胶卷预设列表来提供倒易率失效时的曝光补偿。\n\n您可以在 GitHub 上获取 Lightmeter 的源代码,欢迎自行编译。不过,如果您想支持开发并获得新功能和更新,请考虑购买 Lightmeter Pro。",
|
||||
"buy": "购买",
|
||||
"tooltipAdd": "添加",
|
||||
"tooltipClose": "关闭",
|
||||
"tooltipExpand": "展开",
|
||||
"tooltipCollapse": "崩溃",
|
||||
"tooltipCopy": "复制",
|
||||
"tooltipDelete": "删除",
|
||||
"tooltipSelectAll": "全选",
|
||||
"tooltipDesecelectAll": "取消全选",
|
||||
"resetToZero": "重置为零",
|
||||
"tooltipUseLightSensor": "使用光线传感器",
|
||||
"tooltipUseCamera": "使用摄像头",
|
||||
"tooltipOpenSettings": "打开设置"
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:lightmeter/application.dart';
|
||||
import 'package:lightmeter/application_wrapper.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
//debugRepaintRainbowEnabled = true;
|
||||
runApp(const Application(Environment.dev()));
|
||||
runApp(const ApplicationWrapper(Environment.dev(), child: Application()));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/application.dart';
|
||||
import 'package:lightmeter/application_wrapper.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/firebase.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await initializeFirebase(handleErrors: true);
|
||||
runApp(const Application(Environment.prod()));
|
||||
runApp(const ApplicationWrapper(Environment.prod(), child: Application()));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/application.dart';
|
||||
import 'package:lightmeter/application_wrapper.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/firebase.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await initializeFirebase(handleErrors: false);
|
||||
runApp(const Application(Environment.prod()));
|
||||
runApp(const ApplicationWrapper(Environment.prod(), child: Application()));
|
||||
}
|
||||
|
|
|
@ -5,4 +5,6 @@ class PlatformConfig {
|
|||
final rational = const String.fromEnvironment('cameraPreviewAspectRatio').split('/');
|
||||
return int.parse(rational[0]) / int.parse(rational[1]);
|
||||
}
|
||||
|
||||
static String get cameraStubImage => const String.fromEnvironment('cameraStubImage');
|
||||
}
|
||||
|
|
|
@ -2,13 +2,14 @@ import 'dart:async';
|
|||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:exif/exif.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:lightmeter/interactors/metering_interactor.dart';
|
||||
import 'package:lightmeter/platform_config.dart';
|
||||
import 'package:lightmeter/screens/metering/communication/bloc_communication_metering.dart';
|
||||
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart'
|
||||
as communication_event;
|
||||
|
@ -32,7 +33,7 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
|
|||
|
||||
static const _exposureMaxRange = RangeValues(-4, 4);
|
||||
RangeValues? _exposureOffsetRange;
|
||||
double _exposureStep = 0.0;
|
||||
double _exposureStep = 0.1;
|
||||
double _currentExposureOffset = 0.0;
|
||||
|
||||
double? _ev100 = 0.0;
|
||||
|
@ -199,21 +200,28 @@ class CameraContainerBloc extends EvSourceBlocBase<CameraContainerEvent, CameraC
|
|||
);
|
||||
}
|
||||
|
||||
bool get _canTakePhoto => !(_cameraController == null ||
|
||||
bool get _canTakePhoto =>
|
||||
PlatformConfig.cameraStubImage.isNotEmpty ||
|
||||
!(_cameraController == null ||
|
||||
!_cameraController!.value.isInitialized ||
|
||||
_cameraController!.value.isTakingPicture);
|
||||
|
||||
Future<double?> _takePhoto() async {
|
||||
try {
|
||||
// https://github.com/flutter/flutter/issues/84957#issuecomment-1661155095
|
||||
|
||||
late final Uint8List bytes;
|
||||
if (PlatformConfig.cameraStubImage.isNotEmpty) {
|
||||
bytes = (await rootBundle.load(PlatformConfig.cameraStubImage)).buffer.asUint8List();
|
||||
} else {
|
||||
await _cameraController!.setFocusMode(FocusMode.locked);
|
||||
await _cameraController!.setExposureMode(ExposureMode.locked);
|
||||
final file = await _cameraController!.takePicture();
|
||||
await _cameraController!.setFocusMode(FocusMode.auto);
|
||||
await _cameraController!.setExposureMode(ExposureMode.auto);
|
||||
|
||||
final Uint8List bytes = await file.readAsBytes();
|
||||
bytes = await file.readAsBytes();
|
||||
Directory(file.path).deleteSync(recursive: true);
|
||||
}
|
||||
|
||||
final tags = await readExifFromBytes(bytes);
|
||||
final iso = double.tryParse("${tags["EXIF ISOSpeedRatings"]}");
|
||||
|
|
|
@ -69,6 +69,9 @@ class _CameraPreviewBuilderState extends State<_CameraPreviewBuilder> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (PlatformConfig.cameraStubImage.isNotEmpty) {
|
||||
return Image.asset(PlatformConfig.cameraStubImage);
|
||||
}
|
||||
return ValueListenableBuilder<bool>(
|
||||
valueListenable: _initializedNotifier,
|
||||
builder: (context, value, child) => value
|
||||
|
|
|
@ -34,6 +34,26 @@ class _DialogFilterState<T> extends State<DialogFilter<T>> {
|
|||
bool get _hasAnySelected => checkboxValues.contains(true);
|
||||
bool get _hasAnyUnselected => checkboxValues.contains(false);
|
||||
|
||||
late final ScrollController _scrollController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
int i = 0;
|
||||
for (; i < checkboxValues.length; i++) {
|
||||
if (checkboxValues[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
_scrollController = ScrollController(initialScrollOffset: Dimens.grid56 * i);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
|
@ -50,6 +70,7 @@ class _DialogFilterState<T> extends State<DialogFilter<T>> {
|
|||
const Divider(),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
controller: _scrollController,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
|
@ -58,6 +58,8 @@ dev_dependencies:
|
|||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- assets/camera_stub_image.jpg
|
||||
|
||||
flutter_intl:
|
||||
enabled: true
|
||||
|
|
Loading…
Reference in a new issue