From 68db0867d468fe1e9c5e24f8296d55e34c3fb5ff Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 3 Jan 2024 18:30:35 -0800 Subject: [PATCH] theme fixups for loading bg image and new chat reaction icon color --- assets/themes/cwtch/theme.yml | 2 ++ lib/themes/cwtch.dart | 2 ++ lib/themes/opaque.dart | 3 +++ lib/themes/yamltheme.dart | 13 +++++++++++++ lib/widgets/messagelist.dart | 2 +- lib/widgets/messagerow.dart | 6 +++--- linux/cwtch | 5 +++++ linux/cwtch.template.sh | 5 +++++ 8 files changed, 34 insertions(+), 4 deletions(-) diff --git a/assets/themes/cwtch/theme.yml b/assets/themes/cwtch/theme.yml index 72c7587c..668b127b 100644 --- a/assets/themes/cwtch/theme.yml +++ b/assets/themes/cwtch/theme.yml @@ -54,6 +54,7 @@ themes: portraitProfileBadgeTextColor: whiteishPurple scrollbarDefaultColor: purple sendHintTextColor: mauvePurple + chatReactionIconColor: mauvePurple textfieldBackgroundColor: deepPurple textfieldBorderColor: deepPurple textfieldErrorColor: hotPink @@ -94,6 +95,7 @@ themes: portraitProfileBadgeTextColor: whitePurple scrollbarDefaultColor: accent sendHintTextColor: purple + chatReactionIconColor: purple textfieldBackgroundColor: purple textfieldBorderColor: purple textfieldErrorColor: hotPink diff --git a/lib/themes/cwtch.dart b/lib/themes/cwtch.dart index 1affc309..cc450853 100644 --- a/lib/themes/cwtch.dart +++ b/lib/themes/cwtch.dart @@ -74,6 +74,7 @@ class CwtchDark extends OpaqueThemeType { get portraitProfileBadgeTextColor => whiteishPurple; get scrollbarDefaultColor => purple; get sendHintTextColor => mauvePurple; + get chatReactionIconColor => mauvePurple; get textfieldBackgroundColor => deepPurple; get textfieldBorderColor => deepPurple; get textfieldErrorColor => hotPink; @@ -118,6 +119,7 @@ class CwtchLight extends OpaqueThemeType { get portraitProfileBadgeTextColor => whitePurple; get scrollbarDefaultColor => accent; get sendHintTextColor => purple; + get chatReactionIconColor => purple; get textfieldBackgroundColor => purple; get textfieldBorderColor => purple; get textfieldErrorColor => hotPink; diff --git a/lib/themes/opaque.dart b/lib/themes/opaque.dart index e012c730..4a598989 100644 --- a/lib/themes/opaque.dart +++ b/lib/themes/opaque.dart @@ -113,6 +113,7 @@ abstract class OpaqueThemeType { get dropShadowColor => red; get toolbarIconColor => red; + get chatReactionIconColor => red; get messageFromMeBackgroundColor => red; get messageFromMeTextColor => red; get messageFromOtherBackgroundColor => red; @@ -122,6 +123,8 @@ abstract class OpaqueThemeType { get chatImage => null; + ImageProvider loadImage(String key) { return AssetImage(""); } + // Sizes double contactOnionTextSize() { return 18; diff --git a/lib/themes/yamltheme.dart b/lib/themes/yamltheme.dart index 98e2304b..7af7dc9e 100644 --- a/lib/themes/yamltheme.dart +++ b/lib/themes/yamltheme.dart @@ -2,8 +2,10 @@ import 'dart:convert'; import 'dart:io'; import 'dart:ui'; +import 'package:cwtch/config.dart'; import 'package:cwtch/themes/cwtch.dart'; import 'package:cwtch/themes/opaque.dart'; +import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:yaml/yaml.dart'; import 'package:path/path.dart' as path; @@ -127,6 +129,7 @@ class YmlTheme extends OpaqueThemeType { get portraitOnlineBusyColor => Color(0xFFEF9A9A) ?? fallbackTheme.portraitOnlineBusyColor; get dropShadowColor => getColor("dropShadowColor") ?? fallbackTheme.dropShadowColor; get toolbarIconColor => getColor("toolbarIconColor") ?? fallbackTheme.toolbarIconColor; + get chatReactionIconColor => getColor("chatReactionIconColor") ?? fallbackTheme.chatReactionIconColor; get messageFromMeBackgroundColor => getColor("messageFromMeBackgroundColor") ?? fallbackTheme.messageFromMeBackgroundColor; get messageFromMeTextColor => getColor("messageFromMeTextColor") ?? fallbackTheme.messageFromMeTextColor; get messageFromOtherBackgroundColor => getColor("messageFromOtherBackgroundColor") ?? fallbackTheme.messageFromOtherBackgroundColor; @@ -135,4 +138,14 @@ class YmlTheme extends OpaqueThemeType { // Images get chatImage => getImage("chatImage") ?? fallbackTheme.chatImage; + + ImageProvider loadImage(String key) { + File f = File(key); + if (f.existsSync()) { + return FileImage(f); + } else { + return AssetImage(key); + } + } + } diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index e71d01e0..65a13c15 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -120,7 +120,7 @@ class _MessageListState extends State { ? (Provider.of(context).theme.chatImage != null) ? DecorationImage( repeat: ImageRepeat.repeat, - image: AssetImage(Provider.of(context).theme.chatImage), + image: Provider.of(context).theme.loadImage(Provider.of(context).theme.chatImage), colorFilter: ColorFilter.mode(Provider.of(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn)) : null : DecorationImage( diff --git a/lib/widgets/messagerow.dart b/lib/widgets/messagerow.dart index 8ec0023a..3de2d4cb 100644 --- a/lib/widgets/messagerow.dart +++ b/lib/widgets/messagerow.dart @@ -96,7 +96,7 @@ class MessageRowState extends State with SingleTickerProviderStateMi Provider.of(context, listen: false).notifyMessageDraftUpdate(); setState(() {}); }, - icon: Icon(Icons.reply, color: Provider.of(context).theme.dropShadowColor))); + icon: Icon(Icons.reply, color: Provider.of(context).theme.chatReactionIconColor))); var settings = Provider.of(context); var pis = Provider.of(context); @@ -119,7 +119,7 @@ class MessageRowState extends State with SingleTickerProviderStateMi onPressed: () { modalShowReplies(context, AppLocalizations.of(context)!.headingReplies, AppLocalizations.of(context)!.messageNoReplies, settings, pis, cis, borderColor, cache, messageID); }, - icon: Icon(CwtchIcons.view_replies, color: Provider.of(context).theme.dropShadowColor))); + icon: Icon(CwtchIcons.view_replies, color: Provider.of(context).theme.chatReactionIconColor))); var profile = Provider.of(context, listen: false); var conversation = Provider.of(context, listen: false); @@ -143,7 +143,7 @@ class MessageRowState extends State with SingleTickerProviderStateMi Provider.of(context, listen: false).cwtch.TranslateMessage(profile.onion, conversation.identifier, message.messageID, "French"); modalShowTranslation(context, profile, settings); }, - icon: Icon(Icons.translate, color: Provider.of(context).theme.dropShadowColor))); + icon: Icon(Icons.translate, color: Provider.of(context).theme.chatReactionIconColor))); Widget wdgSpacer = Flexible(flex: 1, child: SizedBox(width: Platform.isAndroid ? 20 : 60, height: 10)); var widgetRow = []; diff --git a/linux/cwtch b/linux/cwtch index 3c9e1ec9..65c69716 100755 --- a/linux/cwtch +++ b/linux/cwtch @@ -2,4 +2,9 @@ # Script to run cwtch directly from package tarball directory +SCRIPT=$(realpath "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +cd $SCRIPTPATH + exec env LD_LIBRARY_PATH=./lib/:./lib/Tor ./lib/cwtch diff --git a/linux/cwtch.template.sh b/linux/cwtch.template.sh index 79cde3f4..b3e21338 100755 --- a/linux/cwtch.template.sh +++ b/linux/cwtch.template.sh @@ -1,3 +1,8 @@ #!/bin/sh +SCRIPT=$(realpath "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +cd $SCRIPTPATH + exec env LD_LIBRARY_PATH=PREFIX/lib/cwtch/:PREFIX/lib/cwtch/Tor PREFIX/lib/cwtch/cwtch