Merge pull request 'Fix Lazy Loading for Themes' (#827) from theme-loading-fix into trunk
continuous-integration/drone/push Build is passing Details

Reviewed-on: #827
Reviewed-by: Dan Ballard <dan@openprivacy.ca>
This commit is contained in:
Sarah Jamie Lewis 2024-02-14 04:06:38 +00:00
commit 3d2b960a20
60 changed files with 134 additions and 259 deletions

View File

@ -1,17 +1,8 @@
import 'package:cwtch/main.dart';
import 'package:cwtch/widgets/messagebubble.dart';
import 'package:cwtch/widgets/profilerow.dart';
import 'package:cwtch/widgets/quotedmessage.dart';
import 'package:cwtch/widgets/tor_icon.dart';
import 'package:cwtch/views/profilemgrview.dart';
import 'package:flutter_gherkin/flutter_gherkin.dart';
import 'package:flutter_gherkin/src/flutter/parameters/existence_parameter.dart';
import 'package:flutter_gherkin/src/flutter/parameters/swipe_direction_parameter.dart';
import 'package:gherkin/gherkin.dart';
import 'package:flutter/material.dart';
import 'overrides.dart';
StepDefinitionGeneric ExpectReply() {
return given3<String, String, int, FlutterWorld>(

View File

@ -1,10 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:flutter_gherkin/flutter_gherkin.dart';
import 'package:gherkin/gherkin.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
enum SwitchState { checked, unchecked }
@ -17,6 +14,7 @@ class SwitchStateParameter extends CustomParameter<SwitchState> {
case "unchecked":
return SwitchState.unchecked;
}
return null;
});
}

View File

@ -1,6 +1,5 @@
import 'package:cwtch/themes/opaque.dart';
import 'package:cwtch/third_party/linkify/linkify.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

View File

@ -3,15 +3,10 @@ import 'package:cwtch/cwtch/cwtch.dart';
import 'package:cwtch/main.dart';
import 'package:cwtch/models/appstate.dart';
import 'package:cwtch/models/contact.dart';
import 'package:cwtch/models/message.dart';
import 'package:cwtch/models/profilelist.dart';
import 'package:cwtch/models/profileservers.dart';
import 'package:cwtch/models/remoteserver.dart';
import 'package:cwtch/models/servers.dart';
import 'package:cwtch/notification_manager.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import 'package:cwtch/torstatus.dart';
@ -254,7 +249,7 @@ class CwtchNotifier {
var notification = data["notification"];
// Only bother to do anything if we know about the group and the provided index is greater than our current total...
if (currentTotal != null && idx >= currentTotal) {
if (idx >= currentTotal) {
// TODO: There are 2 timestamps associated with a new group message - time sent and time received.
// Sent refers to the time a profile alleges they sent a message
// Received refers to the time we actually saw the message from the server
@ -346,7 +341,7 @@ class CwtchNotifier {
associatedGroups.forEach((identifier) {
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(int.parse(identifier.toString()))!.antispamTickets = count;
});
EnvironmentConfig.debugLog("update server token count for ${associatedGroups}, $count");
EnvironmentConfig.debugLog("update server token count for $associatedGroups, $count");
} catch (e) {
// No tokens in data...
}

View File

@ -3,7 +3,6 @@ import 'dart:convert';
import 'dart:ffi';
import 'dart:io';
import 'dart:isolate';
import 'dart:io' show Platform;
import 'package:cwtch/cwtch/cwtchNotifier.dart';
import 'package:path/path.dart' as path;
@ -13,7 +12,6 @@ import 'package:cwtch/cwtch/cwtch.dart';
import '../config.dart';
import "package:path/path.dart" show dirname, join;
import 'dart:io' show Platform;
/////////////////////
/// Cwtch API ///

View File

@ -77,7 +77,7 @@ class CwtchGomobile implements Cwtch {
Future<void> Start() async {
print("gomobile.dart: Start()...");
androidHomeDirectoryStr = (await androidHomeDirectory).path;
_cwtchDir = path.join(await androidHomeDirectoryStr, ".cwtch");
_cwtchDir = path.join(androidHomeDirectoryStr, ".cwtch");
if (EnvironmentConfig.BUILD_VER == dev_version) {
_cwtchDir = path.join(_cwtchDir, "dev");
}

View File

@ -1,9 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:isolate';
import 'package:cwtch/config.dart';
import 'package:cwtch/notification_manager.dart';
import 'package:cwtch/themes/cwtch.dart';
import 'package:cwtch/views/doublecolview.dart';
import 'package:cwtch/views/messageview.dart';
import 'package:flutter/foundation.dart';
@ -33,9 +31,7 @@ import 'themes/opaque.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:intl/intl.dart' as intl;
var globalSettings = Settings(Locale("en", ''), CwtchDark());
var globalSettings = Settings(Locale("en", ''));
var globalErrorHandler = ErrorHandler();
var globalTorStatus = TorStatus();
var globalAppState = AppState();
@ -80,7 +76,7 @@ class FlwtchState extends State<Flwtch> with WindowListener {
@override
initState() {
print("initState() started, setting up handlers");
globalSettings = Settings(Locale("en", ''), CwtchDark());
globalSettings = Settings(Locale("en", ''));
globalErrorHandler = ErrorHandler();
globalTorStatus = TorStatus();
globalAppState = AppState();
@ -109,9 +105,11 @@ class FlwtchState extends State<Flwtch> with WindowListener {
}
print("initState: invoking cwtch.Start()");
// Cwtch.start can take time, we don't want it blocking first splash screen draw, so postpone a smidge to let splash render
Future.delayed(const Duration(milliseconds: 50), () async {
await cwtch.Start();
LoadThemes(await cwtch.getCwtchDir());
cwtch.Start().then((vale) {
cwtch.getCwtchDir().then((dir) {
globalSettings.themeloader.LoadThemes(dir);
});
});
print("initState: starting connectivityListener");
if (EnvironmentConfig.TEST_MODE == false) {
@ -128,7 +126,7 @@ class FlwtchState extends State<Flwtch> with WindowListener {
// gracefully fails and NOPs, as it's not a required functionality
startConnectivityListener() async {
try {
connectivityStream = await Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
connectivityStream = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
// Got a new connectivity status!
if (result == ConnectivityResult.none) {
connectivityState = ConnectivityState.confirmed_offline;
@ -161,6 +159,7 @@ class FlwtchState extends State<Flwtch> with WindowListener {
@override
Widget build(BuildContext context) {
globalSettings.initPackageInfo();
return MultiProvider(
providers: [
getFlwtchStateProvider(),
@ -172,10 +171,6 @@ class FlwtchState extends State<Flwtch> with WindowListener {
getServerListStateProvider(),
],
builder: (context, widget) {
// in test mode...rebuild everything every second...if cwtch isn't loaded...
if (EnvironmentConfig.TEST_MODE && cwtch.IsLoaded() == false) {
Timer t = new Timer.periodic(Duration(seconds: 1), (Timer t) => setState(() {}));
}
return Consumer2<Settings, AppState>(
builder: (context, settings, appState, child) => MaterialApp(
key: Key('app'),
@ -193,7 +188,7 @@ class FlwtchState extends State<Flwtch> with WindowListener {
title: 'Cwtch',
showSemanticsDebugger: settings.useSemanticDebugger,
theme: mkThemeData(settings),
home: (!appState.cwtchInit || appState.modalState != ModalState.none) || !cwtch.IsLoaded() ? SplashView() : ProfileMgrView(),
home: (!appState.cwtchInit || appState.modalState != ModalState.none) ? SplashView() : ProfileMgrView(),
),
);
},
@ -256,7 +251,6 @@ class FlwtchState extends State<Flwtch> with WindowListener {
exit(0);
}
}
;
}
// Invoked via notificationClickChannel by MyBroadcastReceiver in MainActivity.kt

View File

@ -1,4 +1,3 @@
import 'package:cwtch/themes/cwtch.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
@ -8,16 +7,14 @@ import 'package:glob/list_local_fs.dart';
import 'config.dart';
import 'licenses.dart';
import 'main.dart';
import 'themes/opaque.dart';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import "package:flutter_driver/driver_extension.dart";
import 'package:flutter_test/flutter_test.dart';
import 'package:glob/glob.dart';
var globalSettings = Settings(Locale("en", ''), CwtchDark());
var globalSettings = Settings(Locale("en", ''));
var globalErrorHandler = ErrorHandler();
Future<void> main() async {

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:cwtch/config.dart';
import 'package:flutter/widgets.dart';
@ -33,13 +32,13 @@ class AppState extends ChangeNotifier {
void SetAppError(String error) {
appError = error;
EnvironmentConfig.debugLog("App Error: ${appError}");
EnvironmentConfig.debugLog("App Error: $appError");
notifyListeners();
}
void SetModalState(ModalState newState) {
modalState = newState;
EnvironmentConfig.debugLog("Modal State: ${newState}");
EnvironmentConfig.debugLog("Modal State: $newState");
notifyListeners();
}

View File

@ -1,5 +1,3 @@
import 'dart:ffi';
import 'package:cwtch/main.dart';
import 'package:cwtch/models/message_draft.dart';
import 'package:cwtch/models/profile.dart';
@ -13,7 +11,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import 'message.dart';
import 'messagecache.dart';
enum ConversationNotificationPolicy {

View File

@ -54,7 +54,7 @@ class ContactListState extends ChangeNotifier {
if (otherGroups != null && otherGroups.isNotEmpty) {
EnvironmentConfig.debugLog("sharing antispam tickets to new group. FIXME: in Cwtch 1.14");
var antispamTickets = otherGroups[0].antispamTickets;
_contacts.last!.antispamTickets = antispamTickets;
_contacts.last.antispamTickets = antispamTickets;
}
servers?.addGroup(newContact);
}

View File

@ -1,5 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
/// A "MessageDraft" structure that stores information about in-progress message drafts.
/// MessageDraft stores text, quoted replies, and attached images.

View File

@ -129,7 +129,7 @@ class MessageCache extends ChangeNotifier {
void addNew(String profileOnion, int conversation, int messageID, DateTime timestamp, String senderHandle, String senderImage, bool isAuto, String data, String contenthash) {
this.cache[messageID] = MessageInfo(MessageMetadata(profileOnion, conversation, messageID, timestamp, senderHandle, senderImage, "", {}, false, false, isAuto, contenthash), data);
this.cacheByIndex.insert(0, LocalIndexMessage(messageID));
if (contenthash != null && contenthash != "") {
if (contenthash != "") {
this.cacheByHash[contenthash] = messageID;
}
}

View File

@ -1,6 +1,5 @@
import 'dart:convert';
import 'package:cwtch/config.dart';
import 'package:cwtch/models/message.dart';
import 'package:cwtch/models/messages/malformedmessage.dart';
import 'package:cwtch/widgets/malformedbubble.dart';
@ -11,7 +10,6 @@ import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import '../../settings.dart';
import '../../third_party/linkify/flutter_linkify.dart';
class QuotedMessageStructure {
final String quotedHash;

View File

@ -1,17 +1,11 @@
import 'dart:math';
import 'package:cwtch/models/message.dart';
import 'package:cwtch/models/messages/malformedmessage.dart';
import 'package:cwtch/widgets/malformedbubble.dart';
import 'package:cwtch/widgets/messagebubble.dart';
import 'package:cwtch/widgets/messageloadingbubble.dart';
import 'package:cwtch/widgets/messagerow.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import '../../settings.dart';
import '../../third_party/linkify/flutter_linkify.dart';
import '../../widgets/messageBubbleWidgetHelpers.dart';
class TextMessage extends Message {
@ -27,7 +21,6 @@ class TextMessage extends Message {
builder: (bcontext, child) {
var formatMessages = Provider.of<Settings>(bcontext).isExperimentEnabled(FormattingExperiment);
return compileMessageContentWidget(context, constraints ?? BoxConstraints.loose(MediaQuery.sizeOf(context)), false, content, FocusNode(), formatMessages, false);
;
});
}

View File

@ -14,8 +14,6 @@ import '../views/contactsview.dart';
import 'contact.dart';
import 'contactlist.dart';
import 'filedownloadprogress.dart';
import 'message.dart';
import 'messagecache.dart';
import 'profileservers.dart';
class ProfileInfoState extends ChangeNotifier {
@ -241,7 +239,7 @@ class ProfileInfoState extends ChangeNotifier {
this._unreadMessages = 0;
this.replaceServers(serverJson);
if (contactsJson != null && contactsJson != "" && contactsJson != "null") {
if (contactsJson != "" && contactsJson != "null") {
List<dynamic> contacts = jsonDecode(contactsJson);
contacts.forEach((contact) {
var profileContact = this._contacts.getContact(contact["identifier"]);

View File

@ -1,6 +1,3 @@
import 'dart:ui';
import 'package:cwtch/config.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';

View File

@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

View File

@ -1,4 +1,3 @@
import 'package:cwtch/config.dart';
import 'package:flutter/cupertino.dart';
import 'contact.dart';

View File

@ -3,13 +3,8 @@ import 'dart:convert';
import 'dart:io';
import 'package:cwtch/main.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:win_toast/win_toast.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_local_notifications_linux/flutter_local_notifications_linux.dart';
import 'package:flutter_local_notifications_linux/src/model/hint.dart';
import 'package:flutter_local_notifications_linux/src/model/icon.dart';
import 'package:path/path.dart' as path;

View File

@ -1,8 +1,6 @@
import 'dart:collection';
import 'dart:ui';
import 'dart:core';
import 'package:cwtch/themes/cwtch.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
@ -42,7 +40,6 @@ enum NotificationContent {
class Settings extends ChangeNotifier {
Locale locale;
late PackageInfo packageInfo;
OpaqueThemeType theme;
bool _themeImages = false;
// explicitly set experiments to false until told otherwise...
@ -70,6 +67,8 @@ class Settings extends ChangeNotifier {
bool _useSemanticDebugger = false;
double _fontScaling = 1.0;
ThemeLoader themeloader = ThemeLoader();
String get torCacheDir => _torCacheDir;
// Whether to show the profiling interface, not saved
@ -88,8 +87,12 @@ class Settings extends ChangeNotifier {
bool get useSemanticDebugger => _useSemanticDebugger;
String? _themeId;
String? _mode;
OpaqueThemeType get theme => themeloader.getTheme(_themeId, _mode);
void setTheme(String themeId, String mode) {
theme = getTheme(themeId, mode);
_themeId = themeId;
_mode = mode;
notifyListeners();
}
@ -464,7 +467,7 @@ class Settings extends ChangeNotifier {
}
/// Construct a default settings object.
Settings(this.locale, this.theme);
Settings(this.locale);
String _blodeuweddPath = "";
String get blodeuweddPath => _blodeuweddPath;

View File

@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:ui';
import 'dart:core';
import 'package:cwtch/themes/cwtch.dart';
@ -21,36 +20,41 @@ final TextStyle defaultTextStyle = TextStyle(fontFamily: "Inter", fontWeight: Fo
final TextStyle defaultTextButtonStyle = defaultTextStyle.copyWith(fontWeight: FontWeight.bold);
final TextStyle defaultDropDownMenuItemTextStyle = TextStyle(fontFamily: "Inter", fontWeight: FontWeight.bold, fontSize: 16);
Map<String, Map<String, OpaqueThemeType>> themes = Map();
class ThemeLoader extends ChangeNotifier {
Map<String, Map<String, OpaqueThemeType>> themes = Map();
LoadThemes(String cwtchDir) async {
themes = await loadBuiltinThemes();
final customThemes = await loadCustomThemes(path.join(cwtchDir, custom_themes_subdir));
themes.addAll(customThemes);
}
OpaqueThemeType getTheme(String themeId, String mode) {
if (themeId == "") {
themeId = cwtch_theme;
}
if (themeId == mode_light) {
themeId = cwtch_theme;
mode = mode_light;
}
if (themeId == mode_dark) {
themeId = cwtch_theme;
mode = mode_dark;
LoadThemes(String cwtchDir) async {
themes.clear(); // clear themes...
loadBuiltinThemes().then((builtinThemes) {
themes.addAll(builtinThemes);
notifyListeners();
loadCustomThemes(path.join(cwtchDir, custom_themes_subdir)).then((customThemes) {
themes.addAll(customThemes);
notifyListeners();
});
});
}
var theme = themes[themeId]?[mode] ?? themes[themeId]?[flipMode(mode)];
return theme ?? CwtchDark();
}
String flipMode(String mode) {
if (mode == mode_dark) {
return mode_light;
OpaqueThemeType getTheme(String? themeId, String? mode) {
if (themeId == null) {
themeId = cwtch_theme;
}
if (themeId == mode_light) {
mode = mode_light;
}
if (themeId == mode_dark) {
mode = mode_dark;
}
var theme = themes[themeId]?[mode] ?? themes[themeId]?[flipMode(mode ?? mode_dark)];
return theme ?? CwtchDark();
}
String flipMode(String mode) {
if (mode == mode_dark) {
return mode_light;
}
return mode_dark;
}
return mode_dark;
}
Color lighten(Color color, [double amount = 0.15]) {
@ -172,13 +176,11 @@ ThemeData mkThemeData(Settings opaque) {
return ThemeData(
hoverColor: opaque.current().backgroundHilightElementColor.withOpacity(0.5),
visualDensity: VisualDensity.adaptivePlatformDensity,
primarySwatch: getMaterialColor(opaque.current().topbarColor),
primaryIconTheme: IconThemeData(
color: opaque.current().mainTextColor,
),
primaryColor: opaque.current().mainTextColor,
canvasColor: opaque.current().backgroundMainColor,
backgroundColor: opaque.current().backgroundMainColor,
highlightColor: opaque.current().hilightElementColor,
iconTheme: IconThemeData(
color: opaque.current().toolbarIconColor,
@ -282,5 +284,6 @@ ThemeData mkThemeData(Settings opaque) {
snackBarTheme: SnackBarThemeData(
backgroundColor: opaque.current().snackbarBackgroundColor,
contentTextStyle: TextStyle(color: opaque.current().snackbarTextColor),
));
)
);
}

View File

@ -1,13 +1,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:glob/list_local_fs.dart';
import 'package:provider/provider.dart';
import 'package:yaml/yaml.dart';
import 'package:path/path.dart' as path;

View File

@ -24,11 +24,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import 'dart:ui';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'linkify.dart';

View File

@ -9,24 +9,24 @@ class TorStatus extends ChangeNotifier {
TorStatus({this.connected = false, this.progress = 0, this.status = "", this.version = ""});
/// Called by the event bus.
handleUpdate(int new_progress, String new_status) {
handleUpdate(int newProgress, String newStatus) {
if (progress == 100) {
connected = true;
} else {
connected = false;
}
progress = new_progress;
status = new_status;
if (new_progress != 100) {
status = "$new_progress% - $new_status";
progress = newProgress;
status = newStatus;
if (newProgress != 100) {
status = "$newProgress% - $newStatus";
}
notifyListeners();
}
updateVersion(String new_version) {
version = new_version;
updateVersion(String newVersion) {
version = newVersion;
notifyListeners();
}
}

View File

@ -1,12 +1,9 @@
import 'dart:convert';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:cwtch/models/profile.dart';
import 'package:cwtch/models/remoteserver.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:cwtch/errorHandler.dart';
import 'package:cwtch/models/profileservers.dart';
import 'package:cwtch/settings.dart';
import 'package:cwtch/widgets/buttontextfield.dart';
import 'package:cwtch/widgets/cwtchlabel.dart';
@ -237,7 +234,9 @@ class _AddContactViewState extends State<AddContactView> {
controller: ctrlrGroupName,
hintText: AppLocalizations.of(bcontext)!.groupNameLabel,
onChanged: (newValue) {},
validator: (value) {},
validator: (value) {
return null;
},
),
SizedBox(
height: 20,

View File

@ -20,7 +20,6 @@ import '../constants.dart';
import '../cwtch_icons_icons.dart';
import '../errorHandler.dart';
import '../main.dart';
import '../themes/opaque.dart';
import '../settings.dart';
class AddEditProfileView extends StatefulWidget {
@ -154,7 +153,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(onion, "profile.profile-attribute-1", profileAttribute1);
Provider.of<ProfileInfoState>(context, listen: false).attributes[0] = profileAttribute1;
},
hintText: Provider.of<ProfileInfoState>(context).attributes[0] ?? AppLocalizations.of(context)!.profileInfoHint!)),
hintText: Provider.of<ProfileInfoState>(context).attributes[0] ?? AppLocalizations.of(context)!.profileInfoHint)),
Padding(
padding: EdgeInsets.all(5.0),
child: CwtchTextField(
@ -165,7 +164,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(onion, "profile.profile-attribute-2", profileAttribute2);
Provider.of<ProfileInfoState>(context, listen: false).attributes[1] = profileAttribute2;
},
hintText: Provider.of<ProfileInfoState>(context).attributes[1] ?? AppLocalizations.of(context)!.profileInfoHint2!)),
hintText: Provider.of<ProfileInfoState>(context).attributes[1] ?? AppLocalizations.of(context)!.profileInfoHint2)),
Padding(
padding: EdgeInsets.all(5.0),
child: CwtchTextField(
@ -176,7 +175,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(onion, "profile.profile-attribute-3", profileAttribute3);
Provider.of<ProfileInfoState>(context, listen: false).attributes[2] = profileAttribute3;
},
hintText: Provider.of<ProfileInfoState>(context).attributes[2] ?? AppLocalizations.of(context)!.profileInfoHint3!)),
hintText: Provider.of<ProfileInfoState>(context).attributes[2] ?? AppLocalizations.of(context)!.profileInfoHint3)),
],
))
],
@ -258,7 +257,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
onChanged: (bool value) {
Provider.of<ProfileInfoState>(context, listen: false).autostart = value;
if (!Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty) {
if (Provider.of<ProfileInfoState>(context, listen: false).onion.isNotEmpty) {
Provider.of<FlwtchState>(context, listen: false)
.cwtch
.SetProfileAttribute(Provider.of<ProfileInfoState>(context, listen: false).onion, "profile.autostart", value ? "true" : "false");
@ -280,7 +279,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
onChanged: (bool value) {
Provider.of<ProfileInfoState>(context, listen: false).appearOfflineAtStartup = value;
var onion = Provider.of<ProfileInfoState>(context, listen: false).onion;
if (!onion.isEmpty) {
if (onion.isNotEmpty) {
Provider.of<FlwtchState>(context, listen: false).cwtch.SetProfileAttribute(onion, "profile.appear-offline", value ? "true" : "false");
}
},
@ -449,11 +448,11 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
minimumSize: Size(400, 75),
backgroundColor: Provider.of<Settings>(context).theme.backgroundMainColor,
maximumSize: Size(800, 75),
shape: RoundedRectangleBorder(
side: BorderSide(color: Provider.of<Settings>(context).theme.defaultButtonActiveColor, width: 2.0),
borderRadius: BorderRadius.horizontal(left: Radius.circular(180), right: Radius.circular(180))),
primary: Provider.of<Settings>(context).theme.backgroundMainColor,
),
onPressed: () {
showAlertDialog(context);

View File

@ -1,11 +1,9 @@
import 'dart:convert';
import 'package:cwtch/cwtch/cwtch.dart';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:cwtch/models/servers.dart';
import 'package:cwtch/widgets/cwtchlabel.dart';
import 'package:cwtch/widgets/passwordfield.dart';
import 'package:cwtch/widgets/textfield.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter/material.dart';
import 'package:cwtch/settings.dart';
import 'package:provider/provider.dart';
@ -13,7 +11,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../errorHandler.dart';
import '../main.dart';
import '../config.dart';
/// Pane to add or edit a server
class AddEditServerView extends StatefulWidget {
@ -143,7 +140,7 @@ class _AddEditServerViewState extends State<AddEditServerView> {
onChanged: (bool value) {
serverInfoState.setAutostart(value);
if (!serverInfoState.onion.isEmpty) {
if (serverInfoState.onion.isNotEmpty) {
Provider.of<FlwtchState>(context, listen: false).cwtch.SetServerAttribute(serverInfoState.onion, "autostart", value ? "true" : "false");
}
},

View File

@ -19,7 +19,6 @@ import 'package:provider/provider.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../config.dart';
import '../main.dart';
import '../models/message.dart';
import '../models/redaction.dart';
import '../settings.dart';
import '../themes/opaque.dart';
@ -43,12 +42,12 @@ class ContactsView extends StatefulWidget {
// selectConversation can be called from anywhere to set the active conversation
void selectConversation(BuildContext context, int handle, int? messageIndex) {
int? index = null;
int? index;
if (messageIndex != null) {
// this message is loaded
Provider.of<AppState>(context, listen: false).selectedSearchMessage = messageIndex;
Provider.of<AppState>(context, listen: false).initialScrollIndex = messageIndex!;
Provider.of<AppState>(context, listen: false).initialScrollIndex = messageIndex;
EnvironmentConfig.debugLog("Looked up index $messageIndex");
}
@ -243,7 +242,7 @@ class _ContactsViewState extends State<ContactsView> {
color: Colors.white,
),
Expanded(
child: Text(AppLocalizations.of(context)!.availabilityStatusAvailable!,
child: Text(AppLocalizations.of(context)!.availabilityStatusAvailable,
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -256,7 +255,7 @@ class _ContactsViewState extends State<ContactsView> {
color: Colors.yellowAccent,
),
Expanded(
child: Text(AppLocalizations.of(context)!.availabilityStatusAway!,
child: Text(AppLocalizations.of(context)!.availabilityStatusAway,
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -269,7 +268,7 @@ class _ContactsViewState extends State<ContactsView> {
color: Colors.redAccent,
),
Expanded(
child: Text(AppLocalizations.of(context)!.availabilityStatusBusy!,
child: Text(AppLocalizations.of(context)!.availabilityStatusBusy,
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -280,7 +279,7 @@ class _ContactsViewState extends State<ContactsView> {
child: Row(children: [
Icon(CwtchIcons.disconnect_from_contact),
Expanded(
child: Text(AppLocalizations.of(context)!.profileAppearOffline!,
child: Text(AppLocalizations.of(context)!.profileAppearOffline,
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -290,7 +289,7 @@ class _ContactsViewState extends State<ContactsView> {
child: Row(children: [
Icon(CwtchIcons.disconnect_from_contact),
Expanded(
child: Text(AppLocalizations.of(context)!.profileAppearOnline!,
child: Text(AppLocalizations.of(context)!.profileAppearOnline,
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -303,7 +302,7 @@ class _ContactsViewState extends State<ContactsView> {
color: settings.theme.mainTextColor,
),
Expanded(
child: Text((settings.blockUnknownConnections ? AppLocalizations.of(context)!.profileAllowUnknownContacts! : AppLocalizations.of(context)!.profileBlockUnknownContacts!),
child: Text((settings.blockUnknownConnections ? AppLocalizations.of(context)!.profileAllowUnknownContacts : AppLocalizations.of(context)!.profileBlockUnknownContacts),
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -313,7 +312,7 @@ class _ContactsViewState extends State<ContactsView> {
child: Row(children: [
Icon(CwtchIcons.favorite_24dp, color: settings.theme.mainTextColor),
Expanded(
child: Text((enabled ? AppLocalizations.of(context)!.profileDisableProfile! : AppLocalizations.of(context)!.profileEnableProfile!),
child: Text((enabled ? AppLocalizations.of(context)!.profileDisableProfile : AppLocalizations.of(context)!.profileEnableProfile),
textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
@ -326,8 +325,7 @@ class _ContactsViewState extends State<ContactsView> {
color: settings.theme.mainTextColor,
),
Expanded(
child:
Text(AppLocalizations.of(context)!.editProfile!, textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
child: Text(AppLocalizations.of(context)!.editProfile, textAlign: TextAlign.right, style: Provider.of<Settings>(context, listen: false).scaleFonts(defaultTextButtonStyle)))
]),
),
],
@ -640,14 +638,14 @@ class _ContactsViewState extends State<ContactsView> {
});
}
void _showQRCode(String profile_code) {
void _showQRCode(String profileCode) {
showModalBottomSheet<dynamic>(
context: context,
builder: (BuildContext context) {
return Wrap(children: <Widget>[
Center(
child: QrImageView(
data: profile_code,
data: profileCode,
version: QrVersions.auto,
size: 400.0,
backgroundColor: Provider.of<Settings>(context).theme.backgroundPaneColor,

View File

@ -4,7 +4,6 @@ import 'package:cwtch/models/profile.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../main.dart';
import '../settings.dart';
import 'contactsview.dart';
import 'messageview.dart';

View File

@ -10,7 +10,6 @@ import '../config.dart';
import '../cwtch_icons_icons.dart';
import '../main.dart';
import '../settings.dart';
import '../themes/opaque.dart';
import 'globalsettingsview.dart';
class GlobalSettingsAboutView extends StatefulWidget {

View File

@ -14,7 +14,6 @@ import '../settings.dart';
import '../themes/cwtch.dart';
import '../themes/opaque.dart';
import '../themes/yamltheme.dart';
import '../widgets/folderpicker.dart';
import 'globalsettingsview.dart';
class GlobalSettingsAppearanceView extends StatefulWidget {
@ -99,7 +98,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
saveSettings(context);
});
},
items: themes.keys.map<DropdownMenuItem<String>>((String themeId) {
items: settings.themeloader.themes.keys.map<DropdownMenuItem<String>>((String themeId) {
return DropdownMenuItem<String>(
value: themeId,
child: Text(getThemeName(context, themeId), style: settings.scaleFonts(defaultDropDownMenuItemTextStyle)), //"ddi_$themeId", key: Key("ddi_$themeId")),
@ -372,7 +371,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
Directory targetDir = Directory(path.join(themesDir, themeName));
// check if exists
if (themes.containsKey(themeName) || targetDir.existsSync()) {
if (settings.themeloader.themes.containsKey(themeName) || targetDir.existsSync()) {
_modalConfirmOverwriteCustomTheme(srcDir, targetDir, themesDir, themeName, settings);
} else {
importTheme(srcDir, targetDir, themesDir, themeName, settings);
@ -393,7 +392,7 @@ class _GlobalSettingsAppearanceViewState extends State<GlobalSettingsAppearanceV
var data = await loadFileYamlTheme(path.join(targetDir.path, "theme.yml"), targetDir.path);
if (data != null) {
themes[themeName] = data;
settings.themeloader.themes[themeName] = data;
}
if (settings.current().theme == themeName) {

View File

@ -5,7 +5,6 @@ import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../config.dart';
import '../cwtch_icons_icons.dart';
import '../settings.dart';
import '../themes/opaque.dart';

View File

@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../config.dart';
import '../cwtch_icons_icons.dart';
import '../main.dart';
import '../models/servers.dart';

View File

@ -1,24 +1,15 @@
import 'dart:collection';
import 'dart:convert';
import 'dart:io';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:cwtch/models/servers.dart';
import 'package:cwtch/views/globalsettingsaboutview.dart';
import 'package:cwtch/views/globalsettingsappearanceview.dart';
import 'package:cwtch/views/globalsettingsbehaviourview.dart';
import 'package:cwtch/views/globalsettingsexperimentsview.dart';
import 'package:cwtch/widgets/folderpicker.dart';
import 'package:cwtch/themes/cwtch.dart';
import 'package:cwtch/themes/opaque.dart';
import 'package:flutter/services.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter/material.dart';
import 'package:cwtch/settings.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../main.dart';
import '../config.dart';
/// Global Settings View provides access to modify all the Globally Relevant Settings including Locale, Theme and Experiments.
class GlobalSettingsView extends StatefulWidget {

View File

@ -109,7 +109,9 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
),
CwtchTextField(
controller: TextEditingController(text: Provider.of<ContactInfoState>(context, listen: false).server),
validator: (value) {},
validator: (value) {
return null;
},
hintText: '',
)
]),

View File

@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'dart:ui';
import 'package:crypto/crypto.dart';
import 'package:cwtch/cwtch/cwtch.dart';
import 'package:cwtch/cwtch_icons_icons.dart';

View File

@ -1,5 +1,3 @@
import 'dart:convert';
import 'dart:ui';
import 'package:cwtch/config.dart';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:cwtch/models/appstate.dart';

View File

@ -16,7 +16,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:cwtch/widgets/profilerow.dart';
import 'package:provider/provider.dart';
import '../config.dart';
import '../main.dart';
import '../torstatus.dart';
import 'addeditprofileview.dart';
@ -178,7 +177,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
);
}
void _pushAddProfile(bcontext, {onion: ""}) {
void _pushAddProfile(bcontext, {onion = ""}) {
Navigator.popUntil(bcontext, (route) => route.isFirst);
Navigator.of(context).push(
@ -246,11 +245,11 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
child: ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: Size(399, 20),
backgroundColor: Provider.of<Settings>(context).theme.backgroundMainColor,
maximumSize: Size(400, 20),
shape: RoundedRectangleBorder(
side: BorderSide(color: Provider.of<Settings>(context).theme.defaultButtonActiveColor, width: 2.0),
borderRadius: BorderRadius.horizontal(left: Radius.circular(180), right: Radius.circular(180))),
primary: Provider.of<Settings>(context).theme.backgroundMainColor,
),
child: Text(AppLocalizations.of(context)!.importProfile,
semanticsLabel: AppLocalizations.of(context)!.importProfile,
@ -308,7 +307,9 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
autofocus: true,
controller: ctrlrPassword,
action: unlock,
validator: (value) {},
validator: (value) {
return null;
},
),
SizedBox(
height: 20,

View File

@ -1,26 +1,15 @@
import 'dart:convert';
import 'package:cwtch/cwtch/cwtch.dart';
import 'package:cwtch/cwtch_icons_icons.dart';
import 'package:cwtch/models/contact.dart';
import 'package:cwtch/models/profile.dart';
import 'package:cwtch/models/profileservers.dart';
import 'package:cwtch/models/remoteserver.dart';
import 'package:cwtch/models/servers.dart';
import 'package:cwtch/widgets/buttontextfield.dart';
import 'package:cwtch/widgets/contactrow.dart';
import 'package:cwtch/widgets/cwtchlabel.dart';
import 'package:cwtch/widgets/passwordfield.dart';
import 'package:cwtch/widgets/textfield.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter/material.dart';
import 'package:cwtch/settings.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../errorHandler.dart';
import '../main.dart';
import '../config.dart';
import '../models/appstate.dart';
import '../themes/opaque.dart';
/// Pane to add or edit a server

View File

@ -3,8 +3,6 @@ import 'package:cwtch/views/addeditservers.dart';
import 'package:cwtch/widgets/passwordfield.dart';
import 'package:cwtch/widgets/serverrow.dart';
import 'package:flutter/material.dart';
import 'package:cwtch/torstatus.dart';
import 'package:cwtch/widgets/tor_icon.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -112,7 +110,9 @@ class _ServersView extends State<ServersView> {
autofocus: true,
controller: ctrlrPassword,
action: unlock,
validator: (value) {},
validator: (value) {
return null;
},
),
SizedBox(
height: 20,

View File

@ -1,6 +1,6 @@
import 'package:cwtch/config.dart';
import 'package:cwtch/models/appstate.dart';
import 'package:cwtch/themes/opaque.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@ -16,6 +16,7 @@ class SplashView extends StatefulWidget {
class _SplashViewState extends State<SplashView> {
@override