mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 00:40:39 +00:00
Fixed CameraPreview
aspect ratio
Probably will be changed in future, is it currently relies on the `ResolutionPreset` being tied with aspect ratio
This commit is contained in:
parent
56480cca0a
commit
5eb0869aa0
4 changed files with 66 additions and 20 deletions
34
.vscode/launch.json
vendored
34
.vscode/launch.json
vendored
|
@ -5,12 +5,26 @@
|
|||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "dev",
|
||||
"name": "dev (android)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"dev",
|
||||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=2/3",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
},
|
||||
{
|
||||
"name": "dev (ios)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"dev",
|
||||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=3/4",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
},
|
||||
|
@ -21,16 +35,32 @@
|
|||
"args": [
|
||||
"--flavor",
|
||||
"dev",
|
||||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=3/4",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main_mock.dart",
|
||||
},
|
||||
{
|
||||
"name": "prod",
|
||||
"name": "prod (android)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"prod",
|
||||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=2/3",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
},
|
||||
{
|
||||
"name": "prod (ios)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"prod",
|
||||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=3/4",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
},
|
||||
|
|
|
@ -12,3 +12,10 @@ Some time ago I've started developing the [Material Lightmeter](https://play.goo
|
|||
But as the existing repo contained some sensitive data, that I've pushed due to lack of experience, I had to make a new one. And if creating a new repo, why not rewrite the app from scratch?)
|
||||
|
||||
Without further delay behold my new Lightmeter app inspired by Material You (a.k.a. M3)
|
||||
|
||||
## Build
|
||||
|
||||
```
|
||||
flutter build apk --flavor dev --dart-define cameraPreviewAspectRatio=2/3
|
||||
flutter build apk --flavor dev --dart-define cameraPreviewAspectRatio=2/3
|
||||
```
|
6
lib/platform_config.dart
Normal file
6
lib/platform_config.dart
Normal file
|
@ -0,0 +1,6 @@
|
|||
class PlatformConfig {
|
||||
static double get cameraPreviewAspectRatio {
|
||||
final rational = const String.fromEnvironment('cameraPreviewAspectRatio', defaultValue: "3/4").split('/');
|
||||
return int.parse(rational[0]) / int.parse(rational[1]);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ import 'package:camera/camera.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:lightmeter/platform_config.dart';
|
||||
import 'package:lightmeter/screens/metering/ev_source/camera/bloc_camera.dart';
|
||||
import 'package:lightmeter/screens/metering/ev_source/camera/state_camera.dart';
|
||||
|
||||
|
@ -11,7 +12,8 @@ class CameraView extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AspectRatio(
|
||||
aspectRatio: 3 / 4,
|
||||
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
||||
child: Center(
|
||||
child: BlocBuilder<CameraBloc, CameraState>(
|
||||
buildWhen: (previous, current) => current is CameraInitializedState,
|
||||
builder: (context, state) {
|
||||
|
@ -31,6 +33,7 @@ class CameraView extends StatelessWidget {
|
|||
return const ColoredBox(color: Colors.black);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue