Merge pull request 'fix wiring of loading files for yaml theme images' (#799) from assetsPath into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #799 Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
commit
2abbf223b2
|
@ -14,6 +14,8 @@ abstract class Cwtch {
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<void> ReconnectCwtchForeground();
|
Future<void> ReconnectCwtchForeground();
|
||||||
|
|
||||||
|
String getAssetsDir();
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CreateProfile(String nick, String pass, bool autostart);
|
void CreateProfile(String nick, String pass, bool autostart);
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ class CwtchFfi implements Cwtch {
|
||||||
late Isolate cwtchIsolate;
|
late Isolate cwtchIsolate;
|
||||||
ReceivePort _receivePort = ReceivePort();
|
ReceivePort _receivePort = ReceivePort();
|
||||||
bool _isL10nInit = false;
|
bool _isL10nInit = false;
|
||||||
|
String _assetsDir = path.join(Directory.current.path, "data", "flutter_assets");
|
||||||
|
|
||||||
static String getLibraryPath() {
|
static String getLibraryPath() {
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
|
@ -183,8 +184,10 @@ class CwtchFfi implements Cwtch {
|
||||||
bundledTor = "lib/Tor/tor";
|
bundledTor = "lib/Tor/tor";
|
||||||
} else if (await File(path.join(home, ".local/lib/cwtch/Tor/tor")).exists()) {
|
} else if (await File(path.join(home, ".local/lib/cwtch/Tor/tor")).exists()) {
|
||||||
bundledTor = path.join(home, ".local/lib/cwtch/Tor/tor");
|
bundledTor = path.join(home, ".local/lib/cwtch/Tor/tor");
|
||||||
|
_assetsDir = path.join(home, ".local", "share", "cwtch", "data", "flutter_assets");
|
||||||
} else if (await File("/usr/lib/cwtch/Tor/tor").exists()) {
|
} else if (await File("/usr/lib/cwtch/Tor/tor").exists()) {
|
||||||
bundledTor = "/usr/lib/cwtch/Tor/tor";
|
bundledTor = "/usr/lib/cwtch/Tor/tor";
|
||||||
|
_assetsDir = path.join("usr", "share", "cwtch", "data", "flutter_assets");
|
||||||
} else {
|
} else {
|
||||||
bundledTor = "tor";
|
bundledTor = "tor";
|
||||||
}
|
}
|
||||||
|
@ -193,14 +196,18 @@ class CwtchFfi implements Cwtch {
|
||||||
String currentTor = path.join(Directory.current.absolute.path, "Tor\\Tor\\tor.exe");
|
String currentTor = path.join(Directory.current.absolute.path, "Tor\\Tor\\tor.exe");
|
||||||
if (await File(currentTor).exists()) {
|
if (await File(currentTor).exists()) {
|
||||||
bundledTor = currentTor;
|
bundledTor = currentTor;
|
||||||
|
_assetsDir = path.join(Directory.current.absolute.path, "data", "flutter_assets");
|
||||||
} else {
|
} else {
|
||||||
String exeDir = path.dirname(Platform.resolvedExecutable);
|
String exeDir = path.dirname(Platform.resolvedExecutable);
|
||||||
bundledTor = path.join(exeDir, "Tor\\Tor\\tor.exe");
|
bundledTor = path.join(exeDir, "Tor\\Tor\\tor.exe");
|
||||||
|
_assetsDir = path.join(exeDir, "data", "flutter_assets");
|
||||||
}
|
}
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
cwtchDir = envVars['CWTCH_HOME'] ?? path.join(envVars['HOME']!, "Library/Application Support/Cwtch");
|
cwtchDir = envVars['CWTCH_HOME'] ?? path.join(envVars['HOME']!, "Library/Application Support/Cwtch");
|
||||||
|
_assetsDir = "/Applications/Cwtch.app/Contents/Frameworks/App.framework/Versions/Current/Resources/flutter_assets/";
|
||||||
if (await File("Cwtch.app/Contents/MacOS/Tor/tor").exists()) {
|
if (await File("Cwtch.app/Contents/MacOS/Tor/tor").exists()) {
|
||||||
bundledTor = "Cwtch.app/Contents/MacOS/Tor/tor";
|
bundledTor = "Cwtch.app/Contents/MacOS/Tor/tor";
|
||||||
|
_assetsDir = "Cwtch.app/Contents/Frameworks/App.framework/Versions/Current/Resources/flutter_assets/";
|
||||||
} else if (await File("/Applications/Cwtch.app/Contents/MacOS/Tor/tor").exists()) {
|
} else if (await File("/Applications/Cwtch.app/Contents/MacOS/Tor/tor").exists()) {
|
||||||
bundledTor = "/Applications/Cwtch.app/Contents/MacOS/Tor/tor";
|
bundledTor = "/Applications/Cwtch.app/Contents/MacOS/Tor/tor";
|
||||||
} else if (await File("/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor").exists()) {
|
} else if (await File("/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor").exists()) {
|
||||||
|
@ -257,6 +264,10 @@ class CwtchFfi implements Cwtch {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getAssetsDir() {
|
||||||
|
return _assetsDir;
|
||||||
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<void> ReconnectCwtchForeground() async {
|
Future<void> ReconnectCwtchForeground() async {
|
||||||
var reconnectCwtch = library.lookup<NativeFunction<Void Function()>>("c_ReconnectCwtchForeground");
|
var reconnectCwtch = library.lookup<NativeFunction<Void Function()>>("c_ReconnectCwtchForeground");
|
||||||
|
|
|
@ -62,6 +62,11 @@ class CwtchGomobile implements Cwtch {
|
||||||
appbusEventChannel.setMethodCallHandler(this._handleAppbusEvent);
|
appbusEventChannel.setMethodCallHandler(this._handleAppbusEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getAssetsDir() {
|
||||||
|
// TODO
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<void> Start() async {
|
Future<void> Start() async {
|
||||||
print("gomobile.dart: Start()...");
|
print("gomobile.dart: Start()...");
|
||||||
|
|
|
@ -123,7 +123,7 @@ abstract class OpaqueThemeType {
|
||||||
|
|
||||||
get chatImage => null;
|
get chatImage => null;
|
||||||
|
|
||||||
ImageProvider loadImage(String key) { return AssetImage(""); }
|
ImageProvider loadImage(String key, {BuildContext? context}) { return AssetImage(""); }
|
||||||
|
|
||||||
// Sizes
|
// Sizes
|
||||||
double contactOnionTextSize() {
|
double contactOnionTextSize() {
|
||||||
|
|
|
@ -7,9 +7,12 @@ import 'package:cwtch/themes/cwtch.dart';
|
||||||
import 'package:cwtch/themes/opaque.dart';
|
import 'package:cwtch/themes/opaque.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
|
import '../main.dart';
|
||||||
|
|
||||||
Future<Map<String, Map<String, OpaqueThemeType>>> loadYamlThemes() async {
|
Future<Map<String, Map<String, OpaqueThemeType>>> loadYamlThemes() async {
|
||||||
final manifestJson = await rootBundle.loadString('AssetManifest.json');
|
final manifestJson = await rootBundle.loadString('AssetManifest.json');
|
||||||
final themesList = json.decode(manifestJson).keys.where((String key) => key.startsWith('assets/themes'));
|
final themesList = json.decode(manifestJson).keys.where((String key) => key.startsWith('assets/themes'));
|
||||||
|
@ -139,13 +142,22 @@ class YmlTheme extends OpaqueThemeType {
|
||||||
|
|
||||||
get chatImage => getImage("chatImage") ?? fallbackTheme.chatImage;
|
get chatImage => getImage("chatImage") ?? fallbackTheme.chatImage;
|
||||||
|
|
||||||
|
ImageProvider loadImage(String key, {BuildContext? context}) {
|
||||||
ImageProvider loadImage(String key) {
|
|
||||||
File f = File(key);
|
File f = File(key);
|
||||||
if (f.existsSync()) {
|
if (f.existsSync()) {
|
||||||
return FileImage(f);
|
return FileImage(f);
|
||||||
} else {
|
|
||||||
return AssetImage(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (context != null) {
|
||||||
|
File af = File(path.join(Provider
|
||||||
|
.of<FlwtchState>(context, listen: false)
|
||||||
|
.cwtch
|
||||||
|
.getAssetsDir(), key));
|
||||||
|
if (af.existsSync()) {
|
||||||
|
return FileImage(af);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AssetImage(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ class _MessageListState extends State<MessageList> {
|
||||||
? (Provider.of<Settings>(context).theme.chatImage != null)
|
? (Provider.of<Settings>(context).theme.chatImage != null)
|
||||||
? DecorationImage(
|
? DecorationImage(
|
||||||
repeat: ImageRepeat.repeat,
|
repeat: ImageRepeat.repeat,
|
||||||
image: Provider.of<Settings>(context).theme.loadImage(Provider.of<Settings>(context).theme.chatImage),
|
image: Provider.of<Settings>(context).theme.loadImage(Provider.of<Settings>(context).theme.chatImage, context: context),
|
||||||
colorFilter: ColorFilter.mode(Provider.of<Settings>(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn))
|
colorFilter: ColorFilter.mode(Provider.of<Settings>(context).theme.hilightElementColor.withOpacity(0.15), BlendMode.srcIn))
|
||||||
: null
|
: null
|
||||||
: DecorationImage(
|
: DecorationImage(
|
||||||
|
|
Loading…
Reference in New Issue