Skip to content

Commit

Permalink
Setup flavor for StoryPad, Spooky, Community (public Firebase)
Browse files Browse the repository at this point in the history
  • Loading branch information
theachoem committed Dec 29, 2024
1 parent e0c9af3 commit 8b5b8e7
Show file tree
Hide file tree
Showing 27 changed files with 1,261 additions and 109 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,21 @@ app.*.map.json

# FVM Version Cache
.fvm/

# Firebase
android/app/src/spooky/google-services.json
android/app/src/storypad/google-services.json

ios/Firebase/spooky/GoogleService-Info.plist
ios/Firebase/storypad/GoogleService-Info.plist

lib/firebase_options/spooky.dart
lib/firebase_options/storypad.dart

lib/main_spooky.dart
lib/main_storypad.dart

env/spooky.json
env/storypad.json

ios/Flutter/GeneratedDartDefines.xcconfig
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ First journal with Material 3 design! Spooky is a minimalist design application

## Installation

Spooky is developed using Flutter 3.27.1. To run project, use following command.
Ensure you have Flutter 3.27.1 installed. For easy setup and running, the GoogleService-Info.plist, google-services.json, and Dart defines are provided directly in this repo. Simply run the project with:

```s
flutter pub get
flutter run
flutter run --flavor community --dart-define-from-file=env/community.json --target=lib/main_community.dart
```

## License
Expand Down
38 changes: 36 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

// remove this when flutter fix following issue:
// https://github.com/flutter/flutter/issues/139289
def dartDefines = [];
if (project.hasProperty('dart-defines')) {
dartDefines = project.property('dart-defines')
.split(',')
.collectEntries { entry ->
def pair = new String(entry.decodeBase64(), 'UTF-8').split('=')
[(pair.first()): pair.last()]
}
}

android {
namespace = "com.juniorise.spooky"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion

Expand All @@ -29,13 +40,36 @@ android {
}

defaultConfig {
applicationId = "com.juniorise.spooky"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName

// --dart-define-from-file=configs/example.json
resValue "string", "app_name", dartDefines.containsKey('APP_NAME') ? dartDefines.APP_NAME : 'Spooky'
}

flavorDimensions "app"
productFlavors {
storypad {
dimension "app"
applicationId "com.tc.writestory"
namespace "com.tc.writestory"
}

community {
dimension "app"
applicationId "com.juniorise.spooky.community"
namespace "com.juniorise.spooky"
}

spooky {
dimension "app"
applicationId "com.juniorise.spooky"
namespace "com.juniorise.spooky"
}
}

signingConfigs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,43 @@
},
"oauth_client": [
{
"client_id": "892248434003-60388oarratalns41v2059obt27kk6kt.apps.googleusercontent.com",
"client_id": "892248434003-7p06aqe80m3s6b6b1iui6llda2m9qcbl.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBn4IK7ySHqwlpYqWjg9BPvHdXuB4HJcy4"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "892248434003-60388oarratalns41v2059obt27kk6kt.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "892248434003-34uc2e5inp4l3fmcvd0bh12ao1sq4pv2.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.juniorise.spooky"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:892248434003:android:5e6ee709875438aa63eda6",
"android_client_info": {
"package_name": "com.juniorise.spooky.community"
}
},
"oauth_client": [
{
"client_id": "892248434003-7p06aqe80m3s6b6b1iui6llda2m9qcbl.apps.googleusercontent.com",
"client_type": 3
}
],
Expand Down Expand Up @@ -50,7 +86,7 @@
},
"oauth_client": [
{
"client_id": "892248434003-60388oarratalns41v2059obt27kk6kt.apps.googleusercontent.com",
"client_id": "892248434003-7p06aqe80m3s6b6b1iui6llda2m9qcbl.apps.googleusercontent.com",
"client_type": 3
}
],
Expand Down Expand Up @@ -86,7 +122,7 @@
},
"oauth_client": [
{
"client_id": "892248434003-60388oarratalns41v2059obt27kk6kt.apps.googleusercontent.com",
"client_id": "892248434003-7p06aqe80m3s6b6b1iui6llda2m9qcbl.apps.googleusercontent.com",
"client_type": 3
}
],
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC" />

<application
android:label="Spooky"
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

Expand Down
5 changes: 5 additions & 0 deletions android/app/src/main/kotlin/com/tc/writestory/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.tc.writestory

import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity()
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
5 changes: 5 additions & 0 deletions env/community.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"APP_NAME": "SpookyC.",
"GOOGLE_CLIENT_ID": "892248434003-q94kghlq2mrmcfucabke2cpmgf77j1p5.apps.googleusercontent.com",
"GOOGLE_REVERSED_CLIENT_ID": "com.googleusercontent.apps.892248434003-q94kghlq2mrmcfucabke2cpmgf77j1p5"
}
2 changes: 1 addition & 1 deletion firebase.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"flutter":{"platforms":{"android":{"default":{"projectId":"juniorise-spooky-community","appId":"1:892248434003:android:07ab4b2c947355a263eda6","fileOutput":"android/app/google-services.json"}},"ios":{"default":{"projectId":"juniorise-spooky-community","appId":"1:892248434003:ios:c1c7f010daf9631363eda6","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"}},"dart":{"lib/firebase_options.dart":{"projectId":"juniorise-spooky-community","configurations":{"android":"1:892248434003:android:07ab4b2c947355a263eda6","ios":"1:892248434003:ios:c1c7f010daf9631363eda6"}}}}}}
{"flutter":{"platforms":{"android":{"default":{"projectId":"juniorise-spooky-community","appId":"1:892248434003:android:07ab4b2c947355a263eda6","fileOutput":"android/app/google-services.json"},"buildConfigurations":{"src/spooky":{"projectId":"juniorise-spooky","appId":"1:845318918007:android:8d9f8265b46011fd349b72","fileOutput":"android/app/src/spooky/google-services.json"},"src/storypad":{"projectId":"tc-write-story","appId":"1:315543702519:android:4e9cf4c1923c1dab74fcf2","fileOutput":"android/app/src/storypad/google-services.json"},"src/community":{"projectId":"juniorise-spooky-community","appId":"1:892248434003:android:5e6ee709875438aa63eda6","fileOutput":"android/app/src/community/google-services.json"}}},"ios":{"default":{"projectId":"juniorise-spooky-community","appId":"1:892248434003:ios:c1c7f010daf9631363eda6","uploadDebugSymbols":false,"fileOutput":"ios/Runner/GoogleService-Info.plist"},"buildConfigurations":{"Release":{"projectId":"tc-write-story","appId":"1:315543702519:ios:b341e734dc53180c74fcf2","uploadDebugSymbols":false,"fileOutput":"ios/Firebase/storypad/GoogleService-Info.plist"}}},"dart":{"lib/firebase_options.dart":{"projectId":"juniorise-spooky-community","configurations":{"android":"1:892248434003:android:07ab4b2c947355a263eda6","ios":"1:892248434003:ios:c1c7f010daf9631363eda6"}},"lib/firebase_options/spooky.dart":{"projectId":"juniorise-spooky","configurations":{"android":"1:845318918007:android:8d9f8265b46011fd349b72","ios":"1:845318918007:ios:6815c46033e54568349b72"}},"lib/firebase_options/storypad.dart":{"projectId":"tc-write-story","configurations":{"android":"1:315543702519:android:4e9cf4c1923c1dab74fcf2","ios":"1:315543702519:ios:b341e734dc53180c74fcf2"}},"lib/firebase_options/community.dart":{"projectId":"juniorise-spooky-community","configurations":{"android":"1:892248434003:android:5e6ee709875438aa63eda6","ios":"1:892248434003:ios:83be1e9203a1be7e63eda6"}}}}}}
87 changes: 87 additions & 0 deletions flutterfire.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash -e

function exit_if_file_not_exist() {
if ! [[ -f $1 ]]; then
echo "🚨 $2"
exit 1
fi
}

function run_command() {
echo -e "\n[EXECUTING] $1\n"
eval $1
}

# eg. main_prod.dart
function save_dart_main_file() {
TEMPLATE_DATA=$(cat "lib/main.dart.template")
FLAVOR=$1
DESTINATION="lib/main_$FLAVOR.dart"

sed "s/#{FLAVOR}/$FLAVOR/g" <<<"$TEMPLATE_DATA" >$DESTINATION
echo "[CREATED] main_flavor.dart.template -> $DESTINATION"
}

function ensure_generated_dart_define_exist() {
touch ios/Flutter/GeneratedDartDefines.xcconfig
}

function configure() {
FLAVOR=$1
PRODUCT=$2
PACKAGE_NAME=$3
WEB_APPLICATION_ID=$4
ACCOUNT=$5
PLATFORMS=${PLATFORMS:-'android,ios'}

save_dart_main_file $FLAVOR
ensure_generated_dart_define_exist

run_command "flutterfire configure
--project=$PRODUCT
--ios-bundle-id=$PACKAGE_NAME
--android-package-name=$PACKAGE_NAME
--macos-bundle-id=$PACKAGE_NAME
--web-app-id=$WEB_APPLICATION_ID
--platforms=$PLATFORMS
--ios-out="ios/Firebase/$FLAVOR/GoogleService-Info.plist"
--android-out=android/app/src/$FLAVOR/google-services.json
--macos-out="macos/Firebase/$FLAVOR/GoogleService-Info.plist"
--out="lib/firebase_options/$FLAVOR.dart"
--ios-build-config=Release-$FLAVOR
--macos-build-config=Release-$FLAVOR
--account=$ACCOUNT
--token=$TOKEN
--yes"
}

function main() {
exit_if_file_not_exist "pubspec.yaml" "Make sure to execute scripts from project directory."

case $1 in

--community)
configure 'community' 'juniorise-spooky-community' 'com.juniorise.spooky.community' '1:892248434003:android:07ab4b2c947355a263eda6' $2
exit 0
;;

--storypad)
configure 'storypad' 'tc-write-story' 'com.tc.writestory' '1:315543702519:android:4e9cf4c1923c1dab74fcf2' $2
exit 0
;;

--spooky)
configure 'spooky' 'juniorise-spooky' 'com.juniorise.spooky' '1:845318918007:android:8d9f8265b46011fd349b72' $2
exit 0
;;

*)
help
exit 0
;;

esac
shift
}

main $@
34 changes: 34 additions & 0 deletions ios/Firebase/community/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>892248434003-q94kghlq2mrmcfucabke2cpmgf77j1p5.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.315543702519-odmt90l1fdih6mtpbcoc1hkqvd8mdhle</string>
<key>API_KEY</key>
<string>AIzaSyAU8Q8SrWFufbf5uC7TPDVC9aDw4_aqvRw</string>
<key>GCM_SENDER_ID</key>
<string>892248434003</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.juniorise.spooky.community</string>
<key>PROJECT_ID</key>
<string>juniorise-spooky-community</string>
<key>STORAGE_BUCKET</key>
<string>juniorise-spooky-community.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:892248434003:ios:83be1e9203a1be7e63eda6</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"

#include "Generated.xcconfig"
#include "GeneratedDartDefines.xcconfig"
2 changes: 2 additions & 0 deletions ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"

#include "Generated.xcconfig"
#include "GeneratedDartDefines.xcconfig"
Loading

0 comments on commit 8b5b8e7

Please sign in to comment.