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 messageFromOtherBackgroundColor => red;
|
||||||
get messageFromOtherTextColor => red;
|
get messageFromOtherTextColor => red;
|
||||||
|
|
||||||
|
// Images
|
||||||
|
|
||||||
|
get chatImage => null;
|
||||||
|
|
||||||
// Sizes
|
// Sizes
|
||||||
double contactOnionTextSize() {
|
double contactOnionTextSize() {
|
||||||
return 18;
|
return 18;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import 'package:cwtch/themes/cwtch.dart';
|
||||||
import 'package:cwtch/themes/opaque.dart';
|
import 'package:cwtch/themes/opaque.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<Map<String, Map<String, OpaqueThemeType>>> loadYamlThemes() async {
|
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);
|
var data = await loadYamlTheme(themefile);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
// remove "assets/themes" and ".yml" from name
|
// remove "assets/themes" and "theme.yml" from name
|
||||||
themes[themefile.substring(14, themefile.length - 4)] = data;
|
var themename = themefile.substring(14, themefile.lastIndexOf("/"));
|
||||||
|
themes[themename] = data;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Failed to load theme: $themefile with exception: $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 {
|
Future<YamlMap?> readAssetYamlTheme(String themefile) async {
|
||||||
print("loading theme: $themefile...");
|
|
||||||
final contents = await rootBundle.loadString(themefile);
|
final contents = await rootBundle.loadString(themefile);
|
||||||
return loadYaml(contents);
|
return loadYaml(contents);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +92,14 @@ class YmlTheme extends OpaqueThemeType {
|
||||||
return Color(0xFF000000 + val as int);
|
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 backgroundMainColor => getColor("backgroundMainColor") ?? fallbackTheme.backgroundMainColor;
|
||||||
get backgroundPaneColor => getColor("backgroundPaneColor") ?? fallbackTheme.backgroundPaneColor;
|
get backgroundPaneColor => getColor("backgroundPaneColor") ?? fallbackTheme.backgroundPaneColor;
|
||||||
get topbarColor => getColor("topbarColor") ?? fallbackTheme.topbarColor;
|
get topbarColor => getColor("topbarColor") ?? fallbackTheme.topbarColor;
|
||||||
|
@ -123,4 +133,8 @@ class YmlTheme extends OpaqueThemeType {
|
||||||
get messageFromMeTextColor => getColor("messageFromMeTextColor") ?? fallbackTheme.messageFromMeTextColor;
|
get messageFromMeTextColor => getColor("messageFromMeTextColor") ?? fallbackTheme.messageFromMeTextColor;
|
||||||
get messageFromOtherBackgroundColor => getColor("messageFromOtherBackgroundColor") ?? fallbackTheme.messageFromOtherBackgroundColor;
|
get messageFromOtherBackgroundColor => getColor("messageFromOtherBackgroundColor") ?? fallbackTheme.messageFromOtherBackgroundColor;
|
||||||
get messageFromOtherTextColor => getColor("messageFromOtherTextColor") ?? fallbackTheme.messageFromOtherTextColor;
|
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/message.dart';
|
||||||
import 'package:cwtch/models/messagecache.dart';
|
import 'package:cwtch/models/messagecache.dart';
|
||||||
import 'package:cwtch/models/profile.dart';
|
import 'package:cwtch/models/profile.dart';
|
||||||
|
import 'package:cwtch/themes/opaque.dart';
|
||||||
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
import 'package:cwtch/widgets/messageloadingbubble.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
@ -115,7 +116,12 @@ class _MessageListState extends State<MessageList> {
|
||||||
// Only show broken heart is the contact is offline...
|
// Only show broken heart is the contact is offline...
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
image: Provider.of<ContactInfoState>(outerContext).isOnline()
|
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(
|
: DecorationImage(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
|
10
pubspec.yaml
10
pubspec.yaml
|
@ -107,6 +107,16 @@ flutter:
|
||||||
- assets/profiles/
|
- assets/profiles/
|
||||||
- assets/servers/
|
- assets/servers/
|
||||||
- assets/themes/
|
- 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:
|
fonts:
|
||||||
- family: Cwtch
|
- family: Cwtch
|
||||||
|
|
Loading…
Reference in New Issue