Compare commits

..

No commits in common. "77578f428659d2198b5465d4f1615c05e68b669a" and "bc6d01f87c8834fa6b19d3e4b21cadd979848015" have entirely different histories.

15 changed files with 55 additions and 44 deletions

View file

@ -67,10 +67,12 @@ jobs:
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
- name: Restore 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"
env:
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: |
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
cp $FIREBASE_OPTIONS_PATH ./lib
- name: Install Flutter
uses: subosito/flutter-action@v2

View file

@ -66,9 +66,6 @@ jobs:
- name: Restore 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
uses: subosito/flutter-action@v2
with:

View file

@ -86,10 +86,12 @@ jobs:
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
- name: Restore 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"
env:
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
run: |
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.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.
# Therefore here we have to increment it as well to build an apk with the same build number.

View file

@ -36,9 +36,6 @@ jobs:
if: steps.fetch-iap.conclusion != 'success'
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
with:
channel: "stable"

1
.gitignore vendored
View file

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

15
.vscode/launch.json vendored
View file

@ -61,5 +61,20 @@
],
"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.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": "off"
"editor.wordBasedSuggestions": false
},
"dart.doNotFormat": [
"**/generated/**",

View file

@ -38,19 +38,6 @@ To build this app you need to install Flutter 3.10.0 stable. [How to install](ht
### 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_:
```yaml

View file

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

View file

@ -2,23 +2,39 @@ enum BuildType { dev, prod }
class Environment {
final BuildType buildType;
final String sourceCodeUrl;
final String issuesReportUrl;
final String contactEmail;
final bool hasLightSensor;
const Environment({
required this.buildType,
required this.sourceCodeUrl,
required this.issuesReportUrl,
required this.contactEmail,
this.hasLightSensor = false,
});
const Environment.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;
const Environment.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;
Environment copyWith({bool? hasLightSensor}) => Environment(
buildType: buildType,
sourceCodeUrl: sourceCodeUrl,
issuesReportUrl: issuesReportUrl,
contactEmail: contactEmail,
hasLightSensor: hasLightSensor ?? this.hasLightSensor,
);
}

View file

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

View file

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

View file

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

View file

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

View file

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