Skip to content

Commit

Permalink
Merge pull request #192 from humhub/f-flavored
Browse files Browse the repository at this point in the history
Add flavor support for white label apps
  • Loading branch information
luke- authored Jun 24, 2024
2 parents 2b9409a + 4ef455b commit 0368404
Show file tree
Hide file tree
Showing 57 changed files with 1,196 additions and 434 deletions.
30 changes: 30 additions & 0 deletions .github/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
humhub/app@master:
- source: assets/
deleteOrphaned: true
exclude: |
.env
- source: lib/
deleteOrphaned: true
- source: test/
deleteOrphaned: true
- .gitignore
- .metadata
- analysis_options.yaml
- l10n.yaml
- pubspec.lock
- pubspec.yaml
humhub/app-flavored@master:
- source: assets/
deleteOrphaned: true
exclude: |
.env
- source: lib/
deleteOrphaned: true
- source: test/
deleteOrphaned: true
- .gitignore
- .metadata
- analysis_options.yaml
- l10n.yaml
- pubspec.lock
- pubspec.yaml
17 changes: 17 additions & 0 deletions .github/workflows/sync-to-flavored-repos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Sync HumHub app with app-flavored

on:
push:
branches:
- 'master'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Run GitHub File Sync
uses: BetaHuhn/repo-file-sync-action@v1
with:
GH_PAT: ${{ secrets.GH_PAT }}
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission
android:name="android.permission.USE_FULL_SCREEN_INTENT"
tools:node="remove" />

<application
android:label="HumHub"
Expand Down
File renamed without changes.
File renamed without changes.
Binary file removed assets/opener_animation_reverse_test.riv
Binary file not shown.
8 changes: 4 additions & 4 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PODS:
- OrderedSet (5.0.0)
- package_info_plus (0.4.5):
- Flutter
- permission_handler_apple (9.0.4):
- permission_handler_apple (9.3.0):
- Flutter
- PromisesObjC (2.3.1)
- ReachabilitySwift (5.0.0)
Expand Down Expand Up @@ -174,15 +174,15 @@ SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_app_badger: b87fc231847b03b92ce1412aa351842e7e97932f
flutter_inappwebview: 3d32228f1304635e7c028b0d4252937730bbc6cf
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_native_timezone: 5f05b2de06c9776b4cc70e1839f03de178394d22
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2
GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1
Expand All @@ -192,4 +192,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 548c8331f2ddb6f2f1e6ba81be1123190231f6e9

COCOAPODS: 1.14.2
COCOAPODS: 1.15.2
18 changes: 18 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
1E133FF3E9A1AC81E5CA3EF3 /* [CP] Embed Pods Frameworks */,
023992100ACEB29FB2946A93 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -209,6 +210,23 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
023992100ACEB29FB2946A93 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
1E133FF3E9A1AC81E5CA3EF3 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
3 changes: 3 additions & 0 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import Firebase
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
53 changes: 53 additions & 0 deletions lib/app_flavored.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/flavored/models/humhub.f.dart';
import 'package:humhub/flavored/util/intent_plugin.f.dart';
import 'package:humhub/flavored/util/router.f.dart';
import 'package:humhub/util/loading_provider.dart';
import 'package:humhub/util/notifications/plugin.dart';
import 'package:humhub/util/override_locale.dart';
import 'package:humhub/util/push/push_plugin.dart';
import 'package:humhub/util/storage_service.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class FlavoredApp extends ConsumerStatefulWidget {
const FlavoredApp({super.key});

@override
FlavoredAppState createState() => FlavoredAppState();
}

class FlavoredAppState extends ConsumerState<FlavoredApp> {
@override
Widget build(BuildContext context) {
SecureStorageService.clearSecureStorageOnReinstall();
return IntentPluginF(
child: NotificationPlugin(
child: PushPlugin(
child: OverrideLocale(
builder: (overrideLocale) => Builder(
builder: (context) => MaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: RouterF.initRoute,
routes: RouterF.routes,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
navigatorKey: navigatorKeyF,
builder: (context, child) => LoadingProvider(
child: child!,
),
theme: ThemeData(
fontFamily: 'OpenSans',
),
),
),
),
),
),
);
}
}

final humHubFProvider = FutureProvider<HumHubF>((ref) {
return HumHubF.initialize();
});
57 changes: 57 additions & 0 deletions lib/app_opener.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/util/intent/intent_plugin.dart';
import 'package:humhub/util/loading_provider.dart';
import 'package:humhub/util/notifications/plugin.dart';
import 'package:humhub/util/override_locale.dart';
import 'package:humhub/util/push/push_plugin.dart';
import 'package:humhub/util/router.dart';
import 'package:humhub/util/storage_service.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class OpenerApp extends ConsumerStatefulWidget {
const OpenerApp({super.key});

@override
OpenerAppState createState() => OpenerAppState();
}

class OpenerAppState extends ConsumerState<OpenerApp> {
@override
Widget build(BuildContext context) {
SecureStorageService.clearSecureStorageOnReinstall();
return IntentPlugin(
child: NotificationPlugin(
child: PushPlugin(
child: OverrideLocale(
builder: (overrideLocale) => Builder(
builder: (context) => FutureBuilder<String>(
future: MyRouter.getInitialRoute(ref),
builder: (context, snap) {
if (snap.hasData) {
return MaterialApp(
debugShowCheckedModeBanner: false,
initialRoute: snap.data,
routes: MyRouter.routes,
navigatorKey: navigatorKey,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: overrideLocale,
builder: (context, child) => LoadingProvider(
child: child!,
),
theme: ThemeData(
fontFamily: 'OpenSans',
),
);
}
return const SizedBox.shrink();
},
),
),
),
),
),
);
}
}
7 changes: 1 addition & 6 deletions lib/components/animated_padding_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ class AnimatedPaddingComponent extends StatefulWidget {
}

class AnimatedPaddingComponentState extends State<AnimatedPaddingComponent> {

@override
Widget build(BuildContext context) {
return AnimatedPadding(
duration: const Duration(milliseconds: 500),
padding: widget.padding,
child: widget.child
);
return AnimatedPadding(duration: const Duration(milliseconds: 500), padding: widget.padding, child: widget.child);
}
}
4 changes: 3 additions & 1 deletion lib/components/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ class BottomNavigationState extends State<BottomNavigation> with TickerProviderS
child: TextButton(
onPressed: () => navigateForth(),
child: Text(
selectedIndex != widget.pageCount - 1 ? AppLocalizations.of(context)!.next : AppLocalizations.of(context)!.connect_now,
selectedIndex != widget.pageCount - 1
? AppLocalizations.of(context)!.next
: AppLocalizations.of(context)!.connect_now,
style: const TextStyle(color: Colors.grey),
),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/components/language_switcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _LanguageSwitcherState extends State<LanguageSwitcher> {
const SizedBox(width: 20),
Text(
locale.toUpperCase(),
style: TextStyle(color: primaryColor, fontSize: 16),
style: TextStyle(color: HumhubTheme.primaryColor, fontSize: 16),
),
],
),
Expand All @@ -56,7 +56,7 @@ class _LanguageSwitcherState extends State<LanguageSwitcher> {
focusedBorder: InputBorder.none,
),
value: _value(context),
icon: Icon(Icons.arrow_drop_down, color: primaryColor),
icon: Icon(Icons.arrow_drop_down, color: HumhubTheme.primaryColor),
items: _items
.mapIndexed(
(localeString, index) => DropdownMenuItem(
Expand All @@ -67,7 +67,7 @@ class _LanguageSwitcherState extends State<LanguageSwitcher> {
const SizedBox(width: 20),
Text(
localeString.toUpperCase(),
style: TextStyle(color: primaryColor, fontSize: 16),
style: TextStyle(color: HumhubTheme.primaryColor, fontSize: 16),
),
],
),
Expand Down
2 changes: 1 addition & 1 deletion lib/components/rotating_globe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _RotatingGlobeState extends State<RotatingGlobe> with TickerProviderStateM

@override
Widget build(BuildContext context) {
if(_controller.isCompleted){
if (_controller.isCompleted) {
_animation = widget.rotationDirection == Direction.left ? _animationSec : _animationFir;
_controller.reset();
}
Expand Down
37 changes: 37 additions & 0 deletions lib/flavored/models/humhub.f.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:humhub/flavored/models/manifest.f.dart';
import 'package:humhub/models/hum_hub.dart';
import 'package:package_info_plus/package_info_plus.dart';

class HumHubF extends HumHub {
@override
ManifestF get manifest => ManifestF.fromEnv();
@override
String get manifestUrl => dotenv.env['MANIFEST_URL']!;
final String bundleId;

HumHubF({
bool isHideOpener = false,
String? randomHash,
String? appVersion,
String? pushToken,
required this.bundleId,
}) : super(
isHideOpener: isHideOpener,
randomHash: HumHub.generateHash(32),
appVersion: appVersion,
pushToken: pushToken);

@override
Map<String, String> get customHeaders => {
'x-humhub-app-token': randomHash!,
'x-humhub-app': appVersion ?? '1.0.0',
'x-humhub-app-bundle-id': bundleId,
'x-humhub-app-ostate': isHideOpener ? '1' : '0'
};

static Future<HumHubF> initialize() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return HumHubF(bundleId: packageInfo.packageName);
}
}
30 changes: 30 additions & 0 deletions lib/flavored/models/manifest.f.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:humhub/models/manifest.dart';

class ManifestF extends Manifest {
ManifestF(
{required String display,
required String startUrl,
required String shortName,
required String name,
required String backgroundColor,
required String themeColor})
: super(
display: display,
startUrl: startUrl,
shortName: shortName,
name: name,
backgroundColor: backgroundColor,
themeColor: themeColor);

factory ManifestF.fromEnv() {
return ManifestF(
display: dotenv.env['DISPLAY']!,
startUrl: dotenv.env['START_URL']!,
shortName: dotenv.env['SHORT_NAME']!,
name: dotenv.env['NAME']!,
backgroundColor: dotenv.env['BACKGROUND_COLOR']!,
themeColor: dotenv.env['THEME_COLOR']!,
);
}
}
Loading

0 comments on commit 0368404

Please sign in to comment.