diff --git a/assets/themes/cwtch.yml b/assets/themes/cwtch/theme.yml similarity index 100% rename from assets/themes/cwtch.yml rename to assets/themes/cwtch/theme.yml diff --git a/assets/themes/ghost.yml b/assets/themes/ghost/theme.yml similarity index 100% rename from assets/themes/ghost.yml rename to assets/themes/ghost/theme.yml diff --git a/assets/themes/juniper.yml b/assets/themes/juniper/theme.yml similarity index 100% rename from assets/themes/juniper.yml rename to assets/themes/juniper/theme.yml diff --git a/assets/themes/mermaid.yml b/assets/themes/mermaid/theme.yml similarity index 100% rename from assets/themes/mermaid.yml rename to assets/themes/mermaid/theme.yml diff --git a/assets/themes/midnight.yml b/assets/themes/midnight/theme.yml similarity index 100% rename from assets/themes/midnight.yml rename to assets/themes/midnight/theme.yml diff --git a/assets/themes/neon1.yml b/assets/themes/neon1/theme.yml similarity index 100% rename from assets/themes/neon1.yml rename to assets/themes/neon1/theme.yml diff --git a/assets/themes/neon2.yml b/assets/themes/neon2/theme.yml similarity index 100% rename from assets/themes/neon2.yml rename to assets/themes/neon2/theme.yml diff --git a/assets/themes/pumpkin.yml b/assets/themes/pumpkin/theme.yml similarity index 100% rename from assets/themes/pumpkin.yml rename to assets/themes/pumpkin/theme.yml diff --git a/assets/themes/vampire.yml b/assets/themes/vampire/theme.yml similarity index 100% rename from assets/themes/vampire.yml rename to assets/themes/vampire/theme.yml diff --git a/assets/themes/witch.yml b/assets/themes/witch/theme.yml similarity index 100% rename from assets/themes/witch.yml rename to assets/themes/witch/theme.yml diff --git a/lib/themes/opaque.dart b/lib/themes/opaque.dart index 9a45c618..74fdca15 100644 --- a/lib/themes/opaque.dart +++ b/lib/themes/opaque.dart @@ -118,6 +118,10 @@ abstract class OpaqueThemeType { get messageFromOtherBackgroundColor => red; get messageFromOtherTextColor => red; + // Images + + get chatImage => null; + // Sizes double contactOnionTextSize() { return 18; diff --git a/lib/themes/yamltheme.dart b/lib/themes/yamltheme.dart index 6131782c..c788d50b 100644 --- a/lib/themes/yamltheme.dart +++ b/lib/themes/yamltheme.dart @@ -6,6 +6,8 @@ import 'package:cwtch/themes/cwtch.dart'; import 'package:cwtch/themes/opaque.dart'; import 'package:flutter/services.dart'; import 'package:yaml/yaml.dart'; +import 'package:path/path.dart' as path; + Future>> loadYamlThemes() async { @@ -23,8 +25,9 @@ Future>> loadYamlThemes() async { var data = await loadYamlTheme(themefile); if (data != null) { - // remove "assets/themes" and ".yml" from name - themes[themefile.substring(14, themefile.length - 4)] = data; + // remove "assets/themes" and "theme.yml" from name + var themename = themefile.substring(14, themefile.lastIndexOf("/")); + themes[themename] = data; } } catch (e) { print("Failed to load theme: $themefile with exception: $e"); @@ -34,7 +37,6 @@ Future>> loadYamlThemes() async { } Future readAssetYamlTheme(String themefile) async { - print("loading theme: $themefile..."); final contents = await rootBundle.loadString(themefile); return loadYaml(contents); } @@ -90,6 +92,14 @@ class YmlTheme extends OpaqueThemeType { return Color(0xFF000000 + val as int); } + String? getImage(String name) { + var val = yml["themes"][mode]["theme"]?[name]; + if (val != null) { + return path.join("assets", "themes", yml["themes"]["name"], val); + } + return null; + } + get backgroundMainColor => getColor("backgroundMainColor") ?? fallbackTheme.backgroundMainColor; get backgroundPaneColor => getColor("backgroundPaneColor") ?? fallbackTheme.backgroundPaneColor; get topbarColor => getColor("topbarColor") ?? fallbackTheme.topbarColor; @@ -123,4 +133,8 @@ class YmlTheme extends OpaqueThemeType { get messageFromMeTextColor => getColor("messageFromMeTextColor") ?? fallbackTheme.messageFromMeTextColor; get messageFromOtherBackgroundColor => getColor("messageFromOtherBackgroundColor") ?? fallbackTheme.messageFromOtherBackgroundColor; get messageFromOtherTextColor => getColor("messageFromOtherTextColor") ?? fallbackTheme.messageFromOtherTextColor; + + // Images + + get chatImage => getImage("chatImage") ?? fallbackTheme.chatImage; } \ No newline at end of file diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index 63635f3b..75623952 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -4,6 +4,7 @@ import 'package:cwtch/models/contact.dart'; import 'package:cwtch/models/message.dart'; import 'package:cwtch/models/messagecache.dart'; import 'package:cwtch/models/profile.dart'; +import 'package:cwtch/themes/opaque.dart'; import 'package:cwtch/widgets/messageloadingbubble.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -115,7 +116,12 @@ class _MessageListState extends State { // Only show broken heart is the contact is offline... decoration: BoxDecoration( image: Provider.of(outerContext).isOnline() - ? null + ? (Provider.of(context).theme.chatImage != null) ? + DecorationImage( + repeat: ImageRepeat.repeat, + image: AssetImage(Provider.of(context).theme.chatImage), + colorFilter: ColorFilter.mode(Provider.of(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn)) + : null : DecorationImage( fit: BoxFit.scaleDown, alignment: Alignment.center, diff --git a/pubspec.yaml b/pubspec.yaml index 2898f6af..fc20f95d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -107,6 +107,16 @@ flutter: - assets/profiles/ - assets/servers/ - assets/themes/ + - assets/themes/cwtch/ + - assets/themes/ghost/ + - assets/themes/juniper/ + - assets/themes/mermaid/ + - assets/themes/midnight/ + - assets/themes/neon1/ + - assets/themes/neon2/ + - assets/themes/pumpkin/ + - assets/themes/vampire/ + - assets/themes/witch/ fonts: - family: Cwtch