Compare commits

..

3 commits

Author SHA1 Message Date
Vadim
77578f4286 fixed PR check workflow 2024-02-19 17:29:25 +01:00
Vadim
d6fb50e63b removed duplicate launch schema 2024-02-19 17:12:02 +01:00
Vadim
98523055aa removed constants from env to the separate file 2024-02-19 17:11:54 +01:00
15 changed files with 44 additions and 55 deletions

View file

@ -67,12 +67,10 @@ jobs:
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
- name: Restore firebase_options.dart - name: Restore firebase_options.dart
env: run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: | - name: Restore constants.dart
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
cp $FIREBASE_OPTIONS_PATH ./lib
- name: Install Flutter - name: Install Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2

View file

@ -66,6 +66,9 @@ jobs:
- name: Restore firebase_options.dart - name: Restore firebase_options.dart
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart" run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
- name: Restore constants.dart
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
- name: Install Flutter - name: Install Flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2
with: with:

View file

@ -86,12 +86,10 @@ jobs:
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
- name: Restore firebase_options.dart - name: Restore firebase_options.dart
env: run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: | - name: Restore constants.dart
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
cp $FIREBASE_OPTIONS_PATH ./lib
# This step makes sense when Github release is enabled because this release increments the build number. # This step makes sense when Github release is enabled because this release increments the build number.
# Therefore here we have to increment it as well to build an apk with the same build number. # Therefore here we have to increment it as well to build an apk with the same build number.

View file

@ -36,6 +36,9 @@ jobs:
if: steps.fetch-iap.conclusion != 'success' if: steps.fetch-iap.conclusion != 'success'
run: bash ./.github/scripts/stub_iap.sh run: bash ./.github/scripts/stub_iap.sh
- name: Restore constants.dart
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.CONSTANTS }}" "lib/constants.dart"
- uses: subosito/flutter-action@v2 - uses: subosito/flutter-action@v2
with: with:
channel: "stable" channel: "stable"

1
.gitignore vendored
View file

@ -58,6 +58,7 @@ android/app/google-services.json
ios/firebase_app_id_file.json ios/firebase_app_id_file.json
ios/Runner/GoogleService-Info.plist ios/Runner/GoogleService-Info.plist
/lib/firebase_options.dart /lib/firebase_options.dart
/lib/constants.dart
coverage/ coverage/
test/coverage_helper_test.dart test/coverage_helper_test.dart

15
.vscode/launch.json vendored
View file

@ -61,20 +61,5 @@
], ],
"program": "${workspaceFolder}/lib/main_dev.dart", "program": "${workspaceFolder}/lib/main_dev.dart",
}, },
{
"name": "dev-simulator",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--flavor",
"dev",
"--dart-define",
"cameraPreviewAspectRatio=240/320",
"--dart-define",
"cameraStubImage=assets/camera_stub_image.jpg"
],
"program": "${workspaceFolder}/lib/main_dev.dart",
},
], ],
} }

View file

@ -16,7 +16,7 @@
"editor.suggest.snippetsPreventQuickSuggestions": false, "editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first", "editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets", "editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false "editor.wordBasedSuggestions": "off"
}, },
"dart.doNotFormat": [ "dart.doNotFormat": [
"**/generated/**", "**/generated/**",

View file

@ -38,6 +38,19 @@ To build this app you need to install Flutter 3.10.0 stable. [How to install](ht
### 2. Project setup ### 2. Project setup
#### Restore _constants.dart_ file
Create a file _lib/constants.dart_ and paste the following content:
```dart
const String contactEmail = '';
const String iapServerUrl = '';
const String issuesReportUrl = '';
const String sourceCodeUrl = '';
```
#### Stub IAP package
As part of the app's functionallity is in the private repo, you have to replace these lines in _pubspec.yaml_: As part of the app's functionallity is in the private repo, you have to replace these lines in _pubspec.yaml_:
```yaml ```yaml

View file

@ -2,9 +2,10 @@ import 'package:flutter/material.dart';
import 'package:m3_lightmeter_iap/src/data/models/iap_product.dart'; import 'package:m3_lightmeter_iap/src/data/models/iap_product.dart';
class IAPProductsProvider extends StatefulWidget { class IAPProductsProvider extends StatefulWidget {
final String apiUrl;
final Widget child; final Widget child;
const IAPProductsProvider({required this.child, super.key}); const IAPProductsProvider({required this.apiUrl, required this.child, super.key});
static IAPProductsProviderState of(BuildContext context) => IAPProductsProvider.maybeOf(context)!; static IAPProductsProviderState of(BuildContext context) => IAPProductsProvider.maybeOf(context)!;

View file

@ -2,39 +2,23 @@ enum BuildType { dev, prod }
class Environment { class Environment {
final BuildType buildType; final BuildType buildType;
final String sourceCodeUrl;
final String issuesReportUrl;
final String contactEmail;
final bool hasLightSensor; final bool hasLightSensor;
const Environment({ const Environment({
required this.buildType, required this.buildType,
required this.sourceCodeUrl,
required this.issuesReportUrl,
required this.contactEmail,
this.hasLightSensor = false, this.hasLightSensor = false,
}); });
const Environment.dev() const Environment.dev()
: buildType = BuildType.dev, : buildType = BuildType.dev,
sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter',
issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues/new/choose',
contactEmail = 'contact.vodemn@gmail.com',
hasLightSensor = false; hasLightSensor = false;
const Environment.prod() const Environment.prod()
: buildType = BuildType.prod, : buildType = BuildType.prod,
sourceCodeUrl = 'https://github.com/vodemn/m3_lightmeter',
issuesReportUrl = 'https://github.com/vodemn/m3_lightmeter/issues/new/choose',
contactEmail = 'contact.vodemn@gmail.com',
hasLightSensor = false; hasLightSensor = false;
Environment copyWith({bool? hasLightSensor}) => Environment( Environment copyWith({bool? hasLightSensor}) => Environment(
buildType: buildType, buildType: buildType,
sourceCodeUrl: sourceCodeUrl,
issuesReportUrl: issuesReportUrl,
contactEmail: contactEmail,
hasLightSensor: hasLightSensor ?? this.hasLightSensor, hasLightSensor: hasLightSensor ?? this.hasLightSensor,
); );
} }

View file

@ -4,6 +4,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:lightmeter/application.dart'; import 'package:lightmeter/application.dart';
import 'package:lightmeter/application_wrapper.dart'; import 'package:lightmeter/application_wrapper.dart';
import 'package:lightmeter/constants.dart';
import 'package:lightmeter/data/analytics/analytics.dart'; import 'package:lightmeter/data/analytics/analytics.dart';
import 'package:lightmeter/data/analytics/api/analytics_firebase.dart'; import 'package:lightmeter/data/analytics/api/analytics_firebase.dart';
import 'package:lightmeter/environment.dart'; import 'package:lightmeter/environment.dart';
@ -27,7 +28,10 @@ Future<void> runLightmeterApp(Environment env) async {
products: [IAPProduct(storeId: IAPProductType.paidFeatures.storeId)], products: [IAPProduct(storeId: IAPProductType.paidFeatures.storeId)],
child: application, child: application,
) )
: IAPProductsProvider(child: application), : IAPProductsProvider(
apiUrl: iapServerUrl,
child: application,
),
); );
}, },
_errorsLogger.logCrash, _errorsLogger.logCrash,

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/constants.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/services_provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class ReportIssueListTile extends StatelessWidget { class ReportIssueListTile extends StatelessWidget {
@ -13,7 +13,7 @@ class ReportIssueListTile extends StatelessWidget {
title: Text(S.of(context).reportIssue), title: Text(S.of(context).reportIssue),
onTap: () { onTap: () {
launchUrl( launchUrl(
Uri.parse(ServicesProvider.of(context).environment.issuesReportUrl), Uri.parse(issuesReportUrl),
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
); );
}, },

View file

@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/constants.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/services_provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class SourceCodeListTile extends StatelessWidget { class SourceCodeListTile extends StatelessWidget {
@ -13,7 +13,7 @@ class SourceCodeListTile extends StatelessWidget {
title: Text(S.of(context).sourceCode), title: Text(S.of(context).sourceCode),
onTap: () { onTap: () {
launchUrl( launchUrl(
Uri.parse(ServicesProvider.of(context).environment.sourceCodeUrl), Uri.parse(sourceCodeUrl),
mode: LaunchMode.externalApplication, mode: LaunchMode.externalApplication,
); );
}, },

View file

@ -1,7 +1,7 @@
import 'package:clipboard/clipboard.dart'; import 'package:clipboard/clipboard.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:lightmeter/constants.dart';
import 'package:lightmeter/generated/l10n.dart'; import 'package:lightmeter/generated/l10n.dart';
import 'package:lightmeter/providers/services_provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class WriteEmailListTile extends StatelessWidget { class WriteEmailListTile extends StatelessWidget {
@ -13,8 +13,7 @@ class WriteEmailListTile extends StatelessWidget {
leading: const Icon(Icons.email), leading: const Icon(Icons.email),
title: Text(S.of(context).writeEmail), title: Text(S.of(context).writeEmail),
onTap: () { onTap: () {
final email = ServicesProvider.of(context).environment.contactEmail; final mailToUrl = Uri.parse('mailto:$contactEmail?subject=M3 Lightmeter');
final mailToUrl = Uri.parse('mailto:$email?subject=M3 Lightmeter');
canLaunchUrl(mailToUrl).then((canLaunch) { canLaunchUrl(mailToUrl).then((canLaunch) {
if (canLaunch) { if (canLaunch) {
launchUrl( launchUrl(
@ -29,7 +28,7 @@ class WriteEmailListTile extends StatelessWidget {
action: SnackBarAction( action: SnackBarAction(
label: S.of(context).copyEmail, label: S.of(context).copyEmail,
onPressed: () { onPressed: () {
FlutterClipboard.copy(email).then((_) { FlutterClipboard.copy(contactEmail).then((_) {
ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).clearSnackBars();
}); });
}, },

View file

@ -28,7 +28,7 @@ dependencies:
m3_lightmeter_iap: m3_lightmeter_iap:
git: git:
url: "https://github.com/vodemn/m3_lightmeter_iap" url: "https://github.com/vodemn/m3_lightmeter_iap"
ref: v0.8.0 ref: v0.8.1
m3_lightmeter_resources: m3_lightmeter_resources:
git: git:
url: "https://github.com/vodemn/m3_lightmeter_resources" url: "https://github.com/vodemn/m3_lightmeter_resources"