mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 16:00:41 +00:00
added env
This commit is contained in:
parent
fbc3804768
commit
6adaeee02d
12 changed files with 58 additions and 42 deletions
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
|
@ -14,7 +14,7 @@
|
|||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=2/3",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
"program": "${workspaceFolder}/lib/main_dev.dart",
|
||||
},
|
||||
{
|
||||
"name": "dev (ios)",
|
||||
|
@ -26,19 +26,7 @@
|
|||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=3/4",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
},
|
||||
{
|
||||
"name": "dev (mock)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": [
|
||||
"--flavor",
|
||||
"dev",
|
||||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=3/4",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main_mock.dart",
|
||||
"program": "${workspaceFolder}/lib/main_dev.dart",
|
||||
},
|
||||
{
|
||||
"name": "prod (android)",
|
||||
|
@ -50,7 +38,7 @@
|
|||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=2/3",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
"program": "${workspaceFolder}/lib/main_prod.dart",
|
||||
},
|
||||
{
|
||||
"name": "prod (ios)",
|
||||
|
@ -62,7 +50,7 @@
|
|||
"--dart-define",
|
||||
"cameraPreviewAspectRatio=3/4",
|
||||
],
|
||||
"program": "${workspaceFolder}/lib/main.dart",
|
||||
"program": "${workspaceFolder}/lib/main_prod.dart",
|
||||
},
|
||||
],
|
||||
}
|
|
@ -2,12 +2,13 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:lightmeter/data/haptics_service.dart';
|
||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'data/models/ev_source_type.dart';
|
||||
import 'data/permissions_service.dart';
|
||||
import 'data/shared_prefs_service.dart';
|
||||
import 'environment.dart';
|
||||
import 'generated/l10n.dart';
|
||||
import 'res/theme.dart';
|
||||
import 'screens/metering/flow_metering.dart';
|
||||
|
@ -17,9 +18,9 @@ import 'utils/stop_type_provider.dart';
|
|||
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
||||
|
||||
class Application extends StatelessWidget {
|
||||
final EvSourceType evSource;
|
||||
final Environment env;
|
||||
|
||||
const Application(this.evSource, {super.key});
|
||||
const Application(this.env, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -29,10 +30,11 @@ class Application extends StatelessWidget {
|
|||
if (snapshot.data != null) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
Provider.value(value: env),
|
||||
Provider.value(value: EvSourceType.camera),
|
||||
Provider(create: (_) => UserPreferencesService(snapshot.data!)),
|
||||
Provider(create: (_) => const HapticsService()),
|
||||
Provider(create: (_) => PermissionsService()),
|
||||
Provider.value(value: evSource),
|
||||
],
|
||||
child: StopTypeProvider(
|
||||
child: ThemeProvider(
|
||||
|
|
|
@ -1 +1 @@
|
|||
enum EvSourceType { camera, mock }
|
||||
enum EvSourceType { camera, sensor }
|
||||
|
|
21
lib/environment.dart
Normal file
21
lib/environment.dart
Normal file
|
@ -0,0 +1,21 @@
|
|||
class Environment {
|
||||
final String sourceCodeUrl;
|
||||
final String issuesReportUrl;
|
||||
final String contactEmail;
|
||||
|
||||
const Environment({
|
||||
required this.sourceCodeUrl,
|
||||
required this.issuesReportUrl,
|
||||
required this.contactEmail,
|
||||
});
|
||||
|
||||
const Environment.dev()
|
||||
: sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter',
|
||||
issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues',
|
||||
contactEmail = '';
|
||||
|
||||
const Environment.prod()
|
||||
: sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter',
|
||||
issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues',
|
||||
contactEmail = '';
|
||||
}
|
9
lib/launch_app.dart
Normal file
9
lib/launch_app.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'application.dart';
|
||||
import 'environment.dart';
|
||||
|
||||
void launchApp(Environment env) {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(Application(env));
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
||||
|
||||
import 'application.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(const Application(EvSourceType.camera));
|
||||
}
|
5
lib/main_dev.dart
Normal file
5
lib/main_dev.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
import 'package:lightmeter/environment.dart';
|
||||
|
||||
import 'launch_app.dart';
|
||||
|
||||
void main() => launchApp(const Environment.dev());
|
|
@ -1,9 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/data/models/ev_source_type.dart';
|
||||
|
||||
import 'application.dart';
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
runApp(const Application(EvSourceType.mock));
|
||||
}
|
5
lib/main_prod.dart
Normal file
5
lib/main_prod.dart
Normal file
|
@ -0,0 +1,5 @@
|
|||
import 'package:lightmeter/environment.dart';
|
||||
|
||||
import 'launch_app.dart';
|
||||
|
||||
void main() => launchApp(const Environment.prod());
|
|
@ -40,7 +40,7 @@ class MeteringFlow extends StatelessWidget {
|
|||
context.read<HapticsInteractor>(),
|
||||
),
|
||||
),
|
||||
if (context.read<EvSourceType>() == EvSourceType.mock)
|
||||
if (context.read<EvSourceType>() == EvSourceType.sensor)
|
||||
BlocProvider(
|
||||
lazy: false,
|
||||
create: (context) => RandomEvBloc(context.read<MeteringCommunicationBloc>()),
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class ReportIssueListTile extends StatelessWidget {
|
||||
|
@ -11,7 +13,7 @@ class ReportIssueListTile extends StatelessWidget {
|
|||
leading: const Icon(Icons.bug_report),
|
||||
title: Text(S.of(context).reportIssue),
|
||||
onTap: () {
|
||||
launchUrl(Uri.parse("https://github.com/vodemn/m3_lightmeter/issues"));
|
||||
launchUrl(Uri.parse(context.read<Environment>().issuesReportUrl));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:lightmeter/environment.dart';
|
||||
import 'package:lightmeter/generated/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class SourceCodeListTile extends StatelessWidget {
|
||||
|
@ -11,7 +13,7 @@ class SourceCodeListTile extends StatelessWidget {
|
|||
leading: const Icon(Icons.code),
|
||||
title: Text(S.of(context).sourceCode),
|
||||
onTap: () {
|
||||
launchUrl(Uri.parse("https://github.com/vodemn/m3_lightmeter"));
|
||||
launchUrl(Uri.parse(context.read<Environment>().sourceCodeUrl));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue