Skip to content

Commit

Permalink
Merge pull request #118 from humhub/117-grey-screen-after-opening-an-…
Browse files Browse the repository at this point in the history
…instance

If the color is not in correct hex format use primary.
  • Loading branch information
luke- committed Oct 12, 2023
2 parents 03d34ab + cf71837 commit 3b03329
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/pages/help/components/second_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class SecondPage extends StatelessWidget {
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
return openerColor;
return primaryColor;
},
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/help/components/third_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ThirdPage extends StatelessWidget {
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
return openerColor;
return primaryColor;
},
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/opener.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class OpenerState extends ConsumerState<Opener> with SingleTickerProviderStateMi
},
child: Text(
'Connect',
style: TextStyle(color: openerColor, fontSize: 20),
style: TextStyle(color: primaryColor, fontSize: 20),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/util/const.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Locales {
static String moreInfoProEditionUrl = "https://www.humhub.com/en/professional-edition";
}

Color openerColor = const Color(0xFF21a1b3);
Color primaryColor = const Color(0xFF21a1b3);

TextStyle? getHeaderStyle(context) {
return Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w600);
Expand Down
16 changes: 12 additions & 4 deletions lib/util/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/models/manifest.dart';
import 'package:humhub/pages/opener.dart';
import 'package:humhub/util/const.dart';
import 'package:humhub/util/providers.dart';
import 'package:loggy/loggy.dart';
import 'package:webview_flutter/webview_flutter.dart';
// ignore_for_file: use_build_context_synchronously
extension MyCookies on WebViewCookieManager {
Expand Down Expand Up @@ -60,11 +62,17 @@ extension MyWebViewController on InAppWebViewController {

class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF$hexColor";
try{
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF$hexColor";
}
return int.parse(hexColor, radix: 16);
}
catch(e){
logError("Color from manifest is not valid use primary color");
return primaryColor.value;
}
return int.parse(hexColor, radix: 16);
}

HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
Expand Down

0 comments on commit 3b03329

Please sign in to comment.