turn themes into directories, add image support, add image support for chat area
This commit is contained in:
parent
6aaa66ea4d
commit
e421642a02
|
@ -118,6 +118,10 @@ abstract class OpaqueThemeType {
|
|||
get messageFromOtherBackgroundColor => red;
|
||||
get messageFromOtherTextColor => red;
|
||||
|
||||
// Images
|
||||
|
||||
get chatImage => null;
|
||||
|
||||
// Sizes
|
||||
double contactOnionTextSize() {
|
||||
return 18;
|
||||
|
|
|
@ -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<Map<String, Map<String, OpaqueThemeType>>> loadYamlThemes() async {
|
||||
|
@ -23,8 +25,9 @@ Future<Map<String, Map<String, OpaqueThemeType>>> 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<Map<String, Map<String, OpaqueThemeType>>> loadYamlThemes() async {
|
|||
}
|
||||
|
||||
Future<YamlMap?> 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;
|
||||
}
|
|
@ -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<MessageList> {
|
|||
// Only show broken heart is the contact is offline...
|
||||
decoration: BoxDecoration(
|
||||
image: Provider.of<ContactInfoState>(outerContext).isOnline()
|
||||
? null
|
||||
? (Provider.of<Settings>(context).theme.chatImage != null) ?
|
||||
DecorationImage(
|
||||
repeat: ImageRepeat.repeat,
|
||||
image: AssetImage(Provider.of<Settings>(context).theme.chatImage),
|
||||
colorFilter: ColorFilter.mode(Provider.of<Settings>(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn))
|
||||
: null
|
||||
: DecorationImage(
|
||||
fit: BoxFit.scaleDown,
|
||||
alignment: Alignment.center,
|
||||
|
|
10
pubspec.yaml
10
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
|
||||
|
|
Loading…
Reference in New Issue