-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from humhub/f-flavored
Add flavor support for white label apps
- Loading branch information
Showing
57 changed files
with
1,196 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}, | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']!, | ||
); | ||
} | ||
} |
Oops, something went wrong.