diff --git a/lib/model.dart b/lib/model.dart index 82246ee0..2106895b 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -282,8 +282,6 @@ class ProfileInfoState extends ChangeNotifier { this._contacts.updateLastMessageTime(this._contacts._contacts.first.identifier, this._contacts._contacts.first.lastMessageTime); } } - - } // Parse out the server list json into our server info state struct... diff --git a/lib/models/profileservers.dart b/lib/models/profileservers.dart index 5f422538..4b868b95 100644 --- a/lib/models/profileservers.dart +++ b/lib/models/profileservers.dart @@ -35,7 +35,7 @@ class ProfileServerListState extends ChangeNotifier { // online v offline if (a.status == "Synced" && b.status != "Synced") { return -1; - } else if (a.status != "Synced" && b.status == "Synced") { + } else if (a.status != "Synced" && b.status == "Synced") { return 1; } @@ -73,7 +73,7 @@ class RemoteServerInfoState extends ChangeNotifier { List _groups = []; RemoteServerInfoState({required this.onion, required this.identifier, required this.description, required this.status}); - + void updateDescription(String newDescription) { this.description = newDescription; notifyListeners(); diff --git a/lib/settings.dart b/lib/settings.dart index c0863991..f961af89 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -37,7 +37,6 @@ class Settings extends ChangeNotifier { bool blockUnknownConnections = false; bool streamerMode = false; - void setTheme(String themeId, String mode) { theme = getTheme(themeId, mode); notifyListeners(); @@ -220,7 +219,6 @@ class Settings extends ChangeNotifier { /// Convert this Settings object to a JSON representation for serialization on the /// event bus. dynamic asJson() { - return { "Locale": this.locale.languageCode, "Theme": theme.theme, diff --git a/lib/themes/cwtch.dart b/lib/themes/cwtch.dart index d0f0b64c..c5c65ae9 100644 --- a/lib/themes/cwtch.dart +++ b/lib/themes/cwtch.dart @@ -93,7 +93,7 @@ class CwtchLight extends OpaqueThemeType { get backgroundPaneColor => header; //softPurple; get backgroundHilightElementColor => softPurple; get mainTextColor => settings; - get sendHintTextColor => purple; + get sendHintTextColor => purple; get hilightElementColor => purple; //darkPurple; // todo shouldn't be this, too dark, makes font unreadable get defaultButtonColor => accent; // hotPink; get defaultButtonTextColor => whitePurple; // ? @@ -118,4 +118,4 @@ class CwtchLight extends OpaqueThemeType { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/ghost.dart b/lib/themes/ghost.dart index 41fe3806..de2d3f2d 100644 --- a/lib/themes/ghost.dart +++ b/lib/themes/ghost.dart @@ -64,4 +64,4 @@ class GhostLight extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/mermaid.dart b/lib/themes/mermaid.dart index 95937e85..c6e21122 100644 --- a/lib/themes/mermaid.dart +++ b/lib/themes/mermaid.dart @@ -64,4 +64,4 @@ class MermaidLight extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/midnight.dart b/lib/themes/midnight.dart index 4dd1b771..da1f1bfd 100644 --- a/lib/themes/midnight.dart +++ b/lib/themes/midnight.dart @@ -64,4 +64,4 @@ class MidnightLight extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/neon1.dart b/lib/themes/neon1.dart index cc8e6adc..fcb4f614 100644 --- a/lib/themes/neon1.dart +++ b/lib/themes/neon1.dart @@ -64,4 +64,4 @@ class Neon1Light extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/neon2.dart b/lib/themes/neon2.dart index c2d551a0..bdfeaf73 100644 --- a/lib/themes/neon2.dart +++ b/lib/themes/neon2.dart @@ -64,4 +64,4 @@ class Neon2Light extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/opaque.dart b/lib/themes/opaque.dart index d71df21f..9e601d32 100644 --- a/lib/themes/opaque.dart +++ b/lib/themes/opaque.dart @@ -17,7 +17,8 @@ import 'neon2.dart'; const mode_light = "light"; const mode_dark = "dark"; -final themes = { cwtch_theme: {mode_light: CwtchLight(), mode_dark: CwtchDark()}, +final themes = { + cwtch_theme: {mode_light: CwtchLight(), mode_dark: CwtchDark()}, ghost_theme: {mode_light: GhostLight(), mode_dark: GhostDark()}, mermaid_theme: {mode_light: MermaidLight(), mode_dark: MermaidDark()}, midnight_theme: {mode_light: MidnightLight(), mode_dark: MidnightDark()}, @@ -169,13 +170,10 @@ ThemeData mkThemeData(Settings opaque) { )), ), ), - scrollbarTheme: ScrollbarThemeData( - isAlwaysShown: false, thumbColor: MaterialStateProperty.all(opaque.current().scrollbarDefaultColor)), + scrollbarTheme: ScrollbarThemeData(isAlwaysShown: false, thumbColor: MaterialStateProperty.all(opaque.current().scrollbarDefaultColor)), tabBarTheme: TabBarTheme(indicator: UnderlineTabIndicator(borderSide: BorderSide(color: opaque.current().defaultButtonActiveColor))), dialogTheme: DialogTheme( - backgroundColor: opaque.current().backgroundPaneColor, - titleTextStyle: TextStyle(color: opaque.current().mainTextColor), - contentTextStyle: TextStyle(color: opaque.current().mainTextColor)), + backgroundColor: opaque.current().backgroundPaneColor, titleTextStyle: TextStyle(color: opaque.current().mainTextColor), contentTextStyle: TextStyle(color: opaque.current().mainTextColor)), textTheme: TextTheme( headline1: TextStyle(color: opaque.current().mainTextColor), headline2: TextStyle(color: opaque.current().mainTextColor), @@ -196,10 +194,7 @@ ThemeData mkThemeData(Settings opaque) { trackColor: MaterialStateProperty.all(opaque.current().dropShadowColor), ), floatingActionButtonTheme: FloatingActionButtonThemeData( - backgroundColor: opaque.current().defaultButtonColor, - hoverColor: opaque.current().defaultButtonActiveColor, - enableFeedback: true, - splashColor: opaque.current().defaultButtonActiveColor), + backgroundColor: opaque.current().defaultButtonColor, hoverColor: opaque.current().defaultButtonActiveColor, enableFeedback: true, splashColor: opaque.current().defaultButtonActiveColor), textSelectionTheme: TextSelectionThemeData( cursorColor: opaque.current().defaultButtonActiveColor, selectionColor: opaque.current().defaultButtonActiveColor, selectionHandleColor: opaque.current().defaultButtonActiveColor), ); diff --git a/lib/themes/pumpkin.dart b/lib/themes/pumpkin.dart index 943c73da..f1c2faef 100644 --- a/lib/themes/pumpkin.dart +++ b/lib/themes/pumpkin.dart @@ -64,4 +64,4 @@ class PumpkinLight extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/vampire.dart b/lib/themes/vampire.dart index 459dfe7b..13bba5b2 100644 --- a/lib/themes/vampire.dart +++ b/lib/themes/vampire.dart @@ -64,4 +64,4 @@ class VampireLight extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/themes/witch.dart b/lib/themes/witch.dart index ebc7d17b..38ad6c8e 100644 --- a/lib/themes/witch.dart +++ b/lib/themes/witch.dart @@ -64,4 +64,4 @@ class WitchLight extends CwtchLight { get messageFromMeTextColor => font; //mainTextColor; get messageFromOtherBackgroundColor => peerBubble; //purple; get messageFromOtherTextColor => font; //darkPurple; -} \ No newline at end of file +} diff --git a/lib/views/addeditprofileview.dart b/lib/views/addeditprofileview.dart index f3dc72dc..95706b92 100644 --- a/lib/views/addeditprofileview.dart +++ b/lib/views/addeditprofileview.dart @@ -107,7 +107,7 @@ class _AddEditProfileViewState extends State { hintText: AppLocalizations.of(context)!.yourDisplayName, validator: (value) { if (value.isEmpty) { - return AppLocalizations.of(context)!.displayNameTooltip; + return AppLocalizations.of(context)!.displayNameTooltip; } return null; }, diff --git a/lib/views/addeditservers.dart b/lib/views/addeditservers.dart index d2d0af22..ede9911a 100644 --- a/lib/views/addeditservers.dart +++ b/lib/views/addeditservers.dart @@ -86,10 +86,10 @@ class _AddEditServerViewState extends State { // Onion Visibility( visible: serverInfoState.onion.isNotEmpty, - child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - CwtchLabel(label: AppLocalizations.of(context)!.serverAddress), - SelectableText(serverInfoState.onion) - ])), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [CwtchLabel(label: AppLocalizations.of(context)!.serverAddress), SelectableText(serverInfoState.onion)])), // Description Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -157,25 +157,18 @@ class _AddEditServerViewState extends State { height: 20, ), Text(AppLocalizations.of(context)!.serverMetricsLabel, style: Provider.of(context).biggerFont), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.serverTotalMessagesLabel), - ]), - Text(serverInfoState.totalMessages.toString()) - ]), - - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(AppLocalizations.of(context)!.serverConnectionsLabel), - ]), - Text(serverInfoState.connections.toString()) - ]), - - + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(AppLocalizations.of(context)!.serverTotalMessagesLabel), + ]), + Text(serverInfoState.totalMessages.toString()) + ]), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Row(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Text(AppLocalizations.of(context)!.serverConnectionsLabel), + ]), + Text(serverInfoState.connections.toString()) + ]), ])), // ***** Password ***** diff --git a/lib/views/contactsview.dart b/lib/views/contactsview.dart index 0c59122e..cfb29b01 100644 --- a/lib/views/contactsview.dart +++ b/lib/views/contactsview.dart @@ -117,7 +117,7 @@ class _ContactsViewState extends State { if (Provider.of(context, listen: false).isExperimentEnabled(TapirGroupsExperiment) || Provider.of(context, listen: false).isExperimentEnabled(ServerManagementExperiment)) { actions.add(IconButton( icon: Icon(CwtchIcons.dns_24px), - tooltip: AppLocalizations.of(context)!.manageKnownServersButton, + tooltip: AppLocalizations.of(context)!.manageKnownServersButton, onPressed: () { _pushServers(); })); diff --git a/lib/views/globalsettingsview.dart b/lib/views/globalsettingsview.dart index 000ed444..e6887350 100644 --- a/lib/views/globalsettingsview.dart +++ b/lib/views/globalsettingsview.dart @@ -91,21 +91,21 @@ class _GlobalSettingsViewState extends State { secondary: Icon(CwtchIcons.change_theme, color: settings.current().mainTextColor), ), ListTile( - title: Text(AppLocalizations.of(context)!.themeColorLabel), - trailing: DropdownButton( - value: Provider.of(context).theme.theme, - onChanged: (String? newValue) { - setState(() { - settings.setTheme(newValue!, settings.theme.mode); - saveSettings(context); - }); - }, - items: themes.keys.map>((String themeId) { - return DropdownMenuItem( - value: themeId, - child: Text(getThemeName(context, themeId)), - ); - }).toList()), + title: Text(AppLocalizations.of(context)!.themeColorLabel), + trailing: DropdownButton( + value: Provider.of(context).theme.theme, + onChanged: (String? newValue) { + setState(() { + settings.setTheme(newValue!, settings.theme.mode); + saveSettings(context); + }); + }, + items: themes.keys.map>((String themeId) { + return DropdownMenuItem( + value: themeId, + child: Text(getThemeName(context, themeId)), + ); + }).toList()), leading: Icon(CwtchIcons.change_theme, color: settings.current().mainTextColor), ), ListTile( @@ -331,15 +331,24 @@ String getLanguageFull(context, String languageCode) { /// Since we don't seem to able to dynamically pull translations, this function maps themes to their names String getThemeName(context, String theme) { switch (theme) { - case cwtch_theme: return AppLocalizations.of(context)!.themeNameCwtch; - case ghost_theme: return AppLocalizations.of(context)!.themeNameGhost; - case mermaid_theme: return AppLocalizations.of(context)!.themeNameMermaid; - case midnight_theme: return AppLocalizations.of(context)!.themeNameMidnight; - case neon1_theme: return AppLocalizations.of(context)!.themeNameNeon1; - case neon2_theme: return AppLocalizations.of(context)!.themeNameNeon2; - case pumpkin_theme: return AppLocalizations.of(context)!.themeNamePumpkin; - case vampire_theme: return AppLocalizations.of(context)!.themeNameVampire; - case witch_theme: return AppLocalizations.of(context)!.themeNameWitch; + case cwtch_theme: + return AppLocalizations.of(context)!.themeNameCwtch; + case ghost_theme: + return AppLocalizations.of(context)!.themeNameGhost; + case mermaid_theme: + return AppLocalizations.of(context)!.themeNameMermaid; + case midnight_theme: + return AppLocalizations.of(context)!.themeNameMidnight; + case neon1_theme: + return AppLocalizations.of(context)!.themeNameNeon1; + case neon2_theme: + return AppLocalizations.of(context)!.themeNameNeon2; + case pumpkin_theme: + return AppLocalizations.of(context)!.themeNamePumpkin; + case vampire_theme: + return AppLocalizations.of(context)!.themeNameVampire; + case witch_theme: + return AppLocalizations.of(context)!.themeNameWitch; } return theme; } diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index 516aadd3..8b803daf 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -314,8 +314,7 @@ class _MessageViewState extends State { children = [composeBox]; } - return Container( - color: Provider.of(context).theme.backgroundMainColor, child: Column(mainAxisSize: MainAxisSize.min, children: children)); + return Container(color: Provider.of(context).theme.backgroundMainColor, child: Column(mainAxisSize: MainAxisSize.min, children: children)); } // Send the message if enter is pressed without the shift key... diff --git a/lib/views/profileserversview.dart b/lib/views/profileserversview.dart index 99040880..1fd029b4 100644 --- a/lib/views/profileserversview.dart +++ b/lib/views/profileserversview.dart @@ -10,14 +10,12 @@ import '../main.dart'; import '../model.dart'; import '../settings.dart'; - class ProfileServersView extends StatefulWidget { @override _ProfileServersView createState() => _ProfileServersView(); } class _ProfileServersView extends State { - @override void dispose() { super.dispose(); @@ -25,9 +23,10 @@ class _ProfileServersView extends State { @override Widget build(BuildContext context) { - - var knownServers = Provider.of(context).serverList.servers.map((RemoteServerInfoState remoteServer) { return remoteServer.onion + ".onion"; }).toSet(); - var importServerList = Provider.of(context).servers.where((server) => !knownServers.contains(server.onion) ).map>((ServerInfoState serverInfo) { + var knownServers = Provider.of(context).serverList.servers.map((RemoteServerInfoState remoteServer) { + return remoteServer.onion + ".onion"; + }).toSet(); + var importServerList = Provider.of(context).servers.where((server) => !knownServers.contains(server.onion)).map>((ServerInfoState serverInfo) { return DropdownMenuItem( value: serverInfo.onion, child: Text( @@ -37,25 +36,22 @@ class _ProfileServersView extends State { ); }).toList(); - importServerList.insert(0, DropdownMenuItem( - value: "", - child: Text(AppLocalizations.of(context)!.importLocalServerSelectText))); + importServerList.insert(0, DropdownMenuItem(value: "", child: Text(AppLocalizations.of(context)!.importLocalServerSelectText))); return Scaffold( appBar: AppBar( - title: Text(MediaQuery - .of(context) - .size - .width > 600 ? AppLocalizations.of(context)!.manageKnownServersLong : AppLocalizations.of(context)!.manageKnownServersShort), + title: Text(MediaQuery.of(context).size.width > 600 ? AppLocalizations.of(context)!.manageKnownServersLong : AppLocalizations.of(context)!.manageKnownServersShort), ), - body: Consumer(builder: (context, profile, child) { + body: Consumer( + builder: (context, profile, child) { ProfileServerListState servers = profile.serverList; - final tiles = servers.servers.map((RemoteServerInfoState server) { - return ChangeNotifierProvider.value( - value: server, - builder: (context, child) => RepaintBoundary(child: RemoteServerRow()), - ); - }, + final tiles = servers.servers.map( + (RemoteServerInfoState server) { + return ChangeNotifierProvider.value( + value: server, + builder: (context, child) => RepaintBoundary(child: RemoteServerRow()), + ); + }, ); final divided = ListTile.divideTiles( @@ -63,37 +59,31 @@ class _ProfileServersView extends State { tiles: tiles, ).toList(); - final importCard = Card( child: ListTile( - title: Text(AppLocalizations.of(context)!.importLocalServerLabel), - leading: Icon(CwtchIcons.add_circle_24px , color: Provider.of(context).current().mainTextColor), - trailing: DropdownButton( - onChanged: (String? importServer) { - if (importServer!.isNotEmpty) { - var server = Provider.of(context).getServer(importServer)!; - showImportConfirm(context, profile.onion, server.onion, server.description, server.serverBundle); - } - - }, - value: "", - items: importServerList, - - ))); + final importCard = Card( + child: ListTile( + title: Text(AppLocalizations.of(context)!.importLocalServerLabel), + leading: Icon(CwtchIcons.add_circle_24px, color: Provider.of(context).current().mainTextColor), + trailing: DropdownButton( + onChanged: (String? importServer) { + if (importServer!.isNotEmpty) { + var server = Provider.of(context).getServer(importServer)!; + showImportConfirm(context, profile.onion, server.onion, server.description, server.serverBundle); + } + }, + value: "", + items: importServerList, + ))); return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) { - return Scrollbar( - isAlwaysShown: true, - child: SingleChildScrollView( - clipBehavior: Clip.antiAlias, - child: - Container( - margin: EdgeInsets.fromLTRB(5, 0, 5, 10), - padding: EdgeInsets.fromLTRB(5, 0, 5, 10), - child: Column(children: [ - - if (importServerList.length > 1) importCard, - - Column( children: divided ) - ]))));}); + return Scrollbar( + isAlwaysShown: true, + child: SingleChildScrollView( + clipBehavior: Clip.antiAlias, + child: Container( + margin: EdgeInsets.fromLTRB(5, 0, 5, 10), + padding: EdgeInsets.fromLTRB(5, 0, 5, 10), + child: Column(children: [if (importServerList.length > 1) importCard, Column(children: divided)])))); + }); return ListView(children: divided); }, @@ -102,7 +92,7 @@ class _ProfileServersView extends State { showImportConfirm(BuildContext context, String profileHandle, String serverHandle, String serverDesc, String bundle) { var serverLabel = serverDesc.isNotEmpty ? serverDesc : serverHandle; - serverHandle = serverHandle.substring(0, serverHandle.length-6 ); // remove '.onion' + serverHandle = serverHandle.substring(0, serverHandle.length - 6); // remove '.onion' // set up the buttons Widget cancelButton = ElevatedButton( child: Text(AppLocalizations.of(context)!.cancel), @@ -118,15 +108,9 @@ class _ProfileServersView extends State { Future.delayed(const Duration(milliseconds: 500), () { var profile = Provider.of(context); if (profile.serverList.getServer(serverHandle) != null) { - profile.serverList.getServer(serverHandle)?.updateDescription( - serverDesc); + profile.serverList.getServer(serverHandle)?.updateDescription(serverDesc); - Provider - .of(context, listen: false) - .cwtch - .SetConversationAttribute(profile.onion, profile.serverList - .getServer(serverHandle) - !.identifier, "server.description", serverDesc); + Provider.of(context, listen: false).cwtch.SetConversationAttribute(profile.onion, profile.serverList.getServer(serverHandle)!.identifier, "server.description", serverDesc); } }); Navigator.of(context).pop(); @@ -149,7 +133,4 @@ class _ProfileServersView extends State { }, ); } - - - -} \ No newline at end of file +} diff --git a/lib/views/remoteserverview.dart b/lib/views/remoteserverview.dart index 1245f7e8..18bcdd04 100644 --- a/lib/views/remoteserverview.dart +++ b/lib/views/remoteserverview.dart @@ -50,63 +50,62 @@ class _RemoteServerViewState extends State { Widget build(BuildContext context) { return Consumer3(builder: (context, profile, serverInfoState, settings, child) { return Scaffold( - appBar: AppBar( - title: Text(ctrlrDesc.text.isNotEmpty ? ctrlrDesc.text : serverInfoState.onion) - ), - body: Container( - margin: EdgeInsets.fromLTRB(30, 0, 30, 10), - padding: EdgeInsets.fromLTRB(20, 0, 20, 10), - child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox( - height: 20, - ), - CwtchLabel(label: AppLocalizations.of(context)!.serverAddress), - SizedBox( - height: 20, - ), - SelectableText( - serverInfoState.onion - ), + appBar: AppBar(title: Text(ctrlrDesc.text.isNotEmpty ? ctrlrDesc.text : serverInfoState.onion)), + body: Container( + margin: EdgeInsets.fromLTRB(30, 0, 30, 10), + padding: EdgeInsets.fromLTRB(20, 0, 20, 10), + child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + SizedBox( + height: 20, + ), + CwtchLabel(label: AppLocalizations.of(context)!.serverAddress), + SizedBox( + height: 20, + ), + SelectableText(serverInfoState.onion), - // Description - SizedBox( - height: 20, - ), - CwtchLabel(label: AppLocalizations.of(context)!.serverDescriptionLabel), - Text(AppLocalizations.of(context)!.serverDescriptionDescription), - SizedBox( - height: 20, - ), - CwtchButtonTextField( - controller: ctrlrDesc, - readonly: false, - tooltip: AppLocalizations.of(context)!.saveBtn, - labelText: AppLocalizations.of(context)!.fieldDescriptionLabel, - icon: Icon(Icons.save), - onPressed: () { - Provider.of(context, listen: false).cwtch.SetConversationAttribute(profile.onion, serverInfoState.identifier, "server.description", ctrlrDesc.text); - serverInfoState.updateDescription(ctrlrDesc.text); - }, - ), + // Description + SizedBox( + height: 20, + ), + CwtchLabel(label: AppLocalizations.of(context)!.serverDescriptionLabel), + Text(AppLocalizations.of(context)!.serverDescriptionDescription), + SizedBox( + height: 20, + ), + CwtchButtonTextField( + controller: ctrlrDesc, + readonly: false, + tooltip: AppLocalizations.of(context)!.saveBtn, + labelText: AppLocalizations.of(context)!.fieldDescriptionLabel, + icon: Icon(Icons.save), + onPressed: () { + Provider.of(context, listen: false).cwtch.SetConversationAttribute(profile.onion, serverInfoState.identifier, "server.description", ctrlrDesc.text); + serverInfoState.updateDescription(ctrlrDesc.text); + }, + ), - SizedBox( - height: 20, - ), + SizedBox( + height: 20, + ), - Padding(padding: EdgeInsets.all(8), child: Text( AppLocalizations.of(context)!.groupsOnThisServerLabel),), - Expanded(child: _buildGroupsList(serverInfoState)) - ]))); - - }); + Padding( + padding: EdgeInsets.all(8), + child: Text(AppLocalizations.of(context)!.groupsOnThisServerLabel), + ), + Expanded(child: _buildGroupsList(serverInfoState)) + ]))); + }); } Widget _buildGroupsList(RemoteServerInfoState serverInfoState) { - final tiles = serverInfoState.groups.map((ContactInfoState group) { - return ChangeNotifierProvider.value( - value: group, - builder: (context, child) => RepaintBoundary(child: _buildGroupRow(group)), // ServerRow()), - ); - }, + final tiles = serverInfoState.groups.map( + (ContactInfoState group) { + return ChangeNotifierProvider.value( + value: group, + builder: (context, child) => RepaintBoundary(child: _buildGroupRow(group)), // ServerRow()), + ); + }, ); final divided = ListTile.divideTiles( @@ -126,26 +125,22 @@ class _RemoteServerViewState extends State { Widget _buildGroupRow(ContactInfoState group) { return Padding( padding: const EdgeInsets.all(6.0), //border size - child: Column( - children: [ - Text( - group.nickname, - style: Provider.of(context).biggerFont.apply(color: Provider.of(context).theme.portraitOnlineBorderColor), - softWrap: true, - overflow: TextOverflow.ellipsis, - ), - Visibility( - visible: !Provider.of(context).streamerMode, - child: ExcludeSemantics( - child: Text( - group.onion, - softWrap: true, - overflow: TextOverflow.ellipsis, - style: TextStyle(color: Provider.of(context).theme.portraitOnlineBorderColor), - ))) - ]) - ); + child: Column(children: [ + Text( + group.nickname, + style: Provider.of(context).biggerFont.apply(color: Provider.of(context).theme.portraitOnlineBorderColor), + softWrap: true, + overflow: TextOverflow.ellipsis, + ), + Visibility( + visible: !Provider.of(context).streamerMode, + child: ExcludeSemantics( + child: Text( + group.onion, + softWrap: true, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: Provider.of(context).theme.portraitOnlineBorderColor), + ))) + ])); } - } - diff --git a/lib/views/splashView.dart b/lib/views/splashView.dart index 4f495066..33eb9097 100644 --- a/lib/views/splashView.dart +++ b/lib/views/splashView.dart @@ -27,8 +27,7 @@ class SplashView extends StatelessWidget { Padding( padding: const EdgeInsets.all(20.0), child: Text(appState.appError == "" ? "Loading Cwtch..." : appState.appError, - style: TextStyle( - fontSize: 16.0, color: appState.appError == "" ? Provider.of(context).theme.mainTextColor : Provider.of(context).theme.textfieldErrorColor)), + style: TextStyle(fontSize: 16.0, color: appState.appError == "" ? Provider.of(context).theme.mainTextColor : Provider.of(context).theme.textfieldErrorColor)), ), Image(image: AssetImage("assets/Open_Privacy_Logo_lightoutline.png")), ])), diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index d9e0a44e..fd49e9fe 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -115,8 +115,7 @@ class FileBubbleState extends State { child: Container( decoration: BoxDecoration( color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor, - border: - Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor, width: 1), + border: Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor, width: 1), borderRadius: BorderRadius.only( topLeft: Radius.circular(borderRadiousEh), topRight: Radius.circular(borderRadiousEh), diff --git a/lib/widgets/invitationbubble.dart b/lib/widgets/invitationbubble.dart index e8ced225..2839b550 100644 --- a/lib/widgets/invitationbubble.dart +++ b/lib/widgets/invitationbubble.dart @@ -97,8 +97,7 @@ class InvitationBubbleState extends State { child: Container( decoration: BoxDecoration( color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor, - border: - Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor, width: 1), + border: Border.all(color: fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor, width: 1), borderRadius: BorderRadius.only( topLeft: Radius.circular(borderRadiousEh), topRight: Radius.circular(borderRadiousEh), diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index ba4ecb95..469a1b5a 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -95,9 +95,7 @@ class MessageBubbleState extends State { child: Container( child: Container( decoration: BoxDecoration( - color: error - ? malformedColor - : (fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor), + color: error ? malformedColor : (fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor), border: Border.all( color: error ? malformedColor diff --git a/lib/widgets/messagebubbledecorations.dart b/lib/widgets/messagebubbledecorations.dart index 3c2ee679..6b740ea9 100644 --- a/lib/widgets/messagebubbledecorations.dart +++ b/lib/widgets/messagebubbledecorations.dart @@ -25,8 +25,7 @@ class _MessageBubbleDecoration extends State { mainAxisSize: MainAxisSize.min, children: [ Text(widget.prettyDate, - style: - TextStyle(fontSize: 9.0, color: widget.fromMe ? Provider.of(context).theme.messageFromMeTextColor : Provider.of(context).theme.messageFromOtherTextColor), + style: TextStyle(fontSize: 9.0, color: widget.fromMe ? Provider.of(context).theme.messageFromMeTextColor : Provider.of(context).theme.messageFromOtherTextColor), textAlign: widget.fromMe ? TextAlign.right : TextAlign.left), !widget.fromMe ? SizedBox(width: 1, height: 1) diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index 32a81b73..57009768 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -37,64 +37,64 @@ class _MessageListState extends State { child: Container( color: Provider.of(context).theme.backgroundMainColor, child: Column(children: [ - Visibility( - visible: showMessageWarning, - child: Container( - padding: EdgeInsets.all(5.0), - color: Provider.of(context).theme.defaultButtonActiveColor, - child: DefaultTextStyle( - style: TextStyle(color: Provider.of(context).theme.defaultButtonTextColor), - child: showSyncing - ? Text(AppLocalizations.of(context)!.serverNotSynced, textAlign: TextAlign.center) - : showOfflineWarning - ? Text(Provider.of(context).isGroup ? AppLocalizations.of(context)!.serverConnectivityDisconnected : AppLocalizations.of(context)!.peerOfflineMessage, - textAlign: TextAlign.center) - // Only show the ephemeral status for peer conversations, not for groups... - : (showEphemeralWarning - ? Text(AppLocalizations.of(context)!.chatHistoryDefault, textAlign: TextAlign.center) - : - // We are not allowed to put null here, so put an empty text widget - Text("")), - ))), - Expanded( - child: Container( - // Only show broken heart is the contact is offline... - decoration: BoxDecoration( - image: Provider.of(outerContext).isOnline() - ? null - : DecorationImage( - fit: BoxFit.scaleDown, - alignment: Alignment.center, - image: AssetImage("assets/core/negative_heart_512px.png"), - colorFilter: ColorFilter.mode(Provider.of(context).theme.hilightElementColor, BlendMode.srcIn))), - // Don't load messages for syncing server... - child: loadMessages - ? ScrollablePositionedList.builder( - itemPositionsListener: widget.scrollListener, - itemScrollController: widget.scrollController, - initialScrollIndex: initi > 4 ? initi - 4 : 0, - itemCount: Provider.of(outerContext).totalMessages, - reverse: true, // NOTE: There seems to be a bug in flutter that corrects the mouse wheel scroll, but not the drag direction... - itemBuilder: (itemBuilderContext, index) { - var profileOnion = Provider.of(outerContext, listen: false).onion; - var contactHandle = Provider.of(outerContext, listen: false).identifier; - var messageIndex = index; + Visibility( + visible: showMessageWarning, + child: Container( + padding: EdgeInsets.all(5.0), + color: Provider.of(context).theme.defaultButtonActiveColor, + child: DefaultTextStyle( + style: TextStyle(color: Provider.of(context).theme.defaultButtonTextColor), + child: showSyncing + ? Text(AppLocalizations.of(context)!.serverNotSynced, textAlign: TextAlign.center) + : showOfflineWarning + ? Text(Provider.of(context).isGroup ? AppLocalizations.of(context)!.serverConnectivityDisconnected : AppLocalizations.of(context)!.peerOfflineMessage, + textAlign: TextAlign.center) + // Only show the ephemeral status for peer conversations, not for groups... + : (showEphemeralWarning + ? Text(AppLocalizations.of(context)!.chatHistoryDefault, textAlign: TextAlign.center) + : + // We are not allowed to put null here, so put an empty text widget + Text("")), + ))), + Expanded( + child: Container( + // Only show broken heart is the contact is offline... + decoration: BoxDecoration( + image: Provider.of(outerContext).isOnline() + ? null + : DecorationImage( + fit: BoxFit.scaleDown, + alignment: Alignment.center, + image: AssetImage("assets/core/negative_heart_512px.png"), + colorFilter: ColorFilter.mode(Provider.of(context).theme.hilightElementColor, BlendMode.srcIn))), + // Don't load messages for syncing server... + child: loadMessages + ? ScrollablePositionedList.builder( + itemPositionsListener: widget.scrollListener, + itemScrollController: widget.scrollController, + initialScrollIndex: initi > 4 ? initi - 4 : 0, + itemCount: Provider.of(outerContext).totalMessages, + reverse: true, // NOTE: There seems to be a bug in flutter that corrects the mouse wheel scroll, but not the drag direction... + itemBuilder: (itemBuilderContext, index) { + var profileOnion = Provider.of(outerContext, listen: false).onion; + var contactHandle = Provider.of(outerContext, listen: false).identifier; + var messageIndex = index; - return FutureBuilder( - future: messageHandler(outerContext, profileOnion, contactHandle, messageIndex), - builder: (context, snapshot) { - if (snapshot.hasData) { - var message = snapshot.data as Message; - var key = Provider.of(outerContext, listen: false).getMessageKey(contactHandle, message.getMetadata().messageID); - return message.getWidget(context, key); - } else { - return MessageLoadingBubble(); - } - }, - ); - }, - ) - : null)) - ]))); + return FutureBuilder( + future: messageHandler(outerContext, profileOnion, contactHandle, messageIndex), + builder: (context, snapshot) { + if (snapshot.hasData) { + var message = snapshot.data as Message; + var key = Provider.of(outerContext, listen: false).getMessageKey(contactHandle, message.getMetadata().messageID); + return message.getWidget(context, key); + } else { + return MessageLoadingBubble(); + } + }, + ); + }, + ) + : null)) + ]))); } } diff --git a/lib/widgets/quotedmessage.dart b/lib/widgets/quotedmessage.dart index 78654f02..e2af135e 100644 --- a/lib/widgets/quotedmessage.dart +++ b/lib/widgets/quotedmessage.dart @@ -90,9 +90,7 @@ class QuotedMessageBubbleState extends State { child: Container( child: Container( decoration: BoxDecoration( - color: error - ? malformedColor - : (fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor), + color: error ? malformedColor : (fromMe ? Provider.of(context).theme.messageFromMeBackgroundColor : Provider.of(context).theme.messageFromOtherBackgroundColor), border: Border.all( color: error ? malformedColor diff --git a/lib/widgets/remoteserverrow.dart b/lib/widgets/remoteserverrow.dart index bd4a8fb8..e7b2417a 100644 --- a/lib/widgets/remoteserverrow.dart +++ b/lib/widgets/remoteserverrow.dart @@ -23,46 +23,42 @@ class _RemoteServerRowState extends State { @override Widget build(BuildContext context) { var server = Provider.of(context); - var description = server.description.isNotEmpty ? server.description : server.onion; + var description = server.description.isNotEmpty ? server.description : server.onion; var running = server.status == "Synced"; - return Consumer( - builder: (context, profile, child) { - return Card(clipBehavior: Clip.antiAlias, + return Consumer(builder: (context, profile, child) { + return Card( + clipBehavior: Clip.antiAlias, margin: EdgeInsets.all(0.0), child: InkWell( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Padding( + padding: const EdgeInsets.all(6.0), //border size + child: Icon(CwtchIcons.dns_24px, + color: running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor, size: 64)), + Expanded( + child: Column( children: [ - Padding( - padding: const EdgeInsets.all(6.0), //border size - child: Icon(CwtchIcons.dns_24px, - color: running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor, - size: 64) - + Text( + description, + semanticsLabel: description, + style: Provider.of(context) + .biggerFont + .apply(color: running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), + softWrap: true, + overflow: TextOverflow.ellipsis, ), - Expanded( - child: Column( - children: [ - Text( - description, - semanticsLabel: description, - style: Provider.of(context).biggerFont.apply(color: running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), - softWrap: true, - overflow: TextOverflow.ellipsis, - ), - Visibility( - visible: !Provider.of(context).streamerMode, - child: ExcludeSemantics( - child: Text( - server.onion, - softWrap: true, - overflow: TextOverflow.ellipsis, - style: TextStyle(color: running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), - ))) - ], - )), - - ]), + Visibility( + visible: !Provider.of(context).streamerMode, + child: ExcludeSemantics( + child: Text( + server.onion, + softWrap: true, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), + ))) + ], + )), + ]), onTap: () { Navigator.of(context).push(MaterialPageRoute( settings: RouteSettings(name: "remoteserverview"), @@ -72,7 +68,7 @@ class _RemoteServerRowState extends State { child: RemoteServerView(), ); })); - } - ));}); - } + })); + }); + } } diff --git a/lib/widgets/serverrow.dart b/lib/widgets/serverrow.dart index 3acac630..2c245b51 100644 --- a/lib/widgets/serverrow.dart +++ b/lib/widgets/serverrow.dart @@ -26,58 +26,57 @@ class _ServerRowState extends State { margin: EdgeInsets.all(0.0), child: InkWell( child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Padding( - padding: const EdgeInsets.all(6.0), //border size - child: Icon(CwtchIcons.dns_24px, - color: server.running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor, size: 64)), - Expanded( - child: Column( - children: [ - Text( - server.description, - semanticsLabel: server.description, - style: Provider.of(context) - .biggerFont - .apply(color: server.running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), - softWrap: true, - overflow: TextOverflow.ellipsis, - ), - Visibility( - visible: !Provider.of(context).streamerMode, - child: ExcludeSemantics( - child: Text( - server.onion, + Padding( + padding: const EdgeInsets.all(6.0), //border size + child: Icon(CwtchIcons.dns_24px, + color: server.running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor, size: 64)), + Expanded( + child: Column( + children: [ + Text( + server.description, + semanticsLabel: server.description, + style: Provider.of(context) + .biggerFont + .apply(color: server.running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), softWrap: true, overflow: TextOverflow.ellipsis, - style: TextStyle(color: server.running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), - ))) - ], - )), + ), + Visibility( + visible: !Provider.of(context).streamerMode, + child: ExcludeSemantics( + child: Text( + server.onion, + softWrap: true, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: server.running ? Provider.of(context).theme.portraitOnlineBorderColor : Provider.of(context).theme.portraitOfflineBorderColor), + ))) + ], + )), - // Copy server button - IconButton( - enableFeedback: true, - tooltip: AppLocalizations.of(context)!.copyServerKeys, - icon: Icon(CwtchIcons.address_copy_2, color: Provider.of(context).current().mainTextColor), - onPressed: () { - Clipboard.setData(new ClipboardData(text: server.serverBundle)); - }, - ), + // Copy server button + IconButton( + enableFeedback: true, + tooltip: AppLocalizations.of(context)!.copyServerKeys, + icon: Icon(CwtchIcons.address_copy_2, color: Provider.of(context).current().mainTextColor), + onPressed: () { + Clipboard.setData(new ClipboardData(text: server.serverBundle)); + }, + ), - // Edit button - IconButton( - enableFeedback: true, - tooltip: AppLocalizations.of(context)!.editServerTitle, - icon: Icon(Icons.create, color: Provider.of(context).current().mainTextColor), - onPressed: () { + // Edit button + IconButton( + enableFeedback: true, + tooltip: AppLocalizations.of(context)!.editServerTitle, + icon: Icon(Icons.create, color: Provider.of(context).current().mainTextColor), + onPressed: () { + _pushEditServer(server); + }, + ) + ]), + onTap: () { _pushEditServer(server); - }, - ) - ]), - onTap: () { - _pushEditServer(server); - } - )); + })); } void _pushEditServer(ServerInfoState server) { diff --git a/lib/widgets/textfield.dart b/lib/widgets/textfield.dart index 3dddd5ee..436bea19 100644 --- a/lib/widgets/textfield.dart +++ b/lib/widgets/textfield.dart @@ -47,7 +47,6 @@ class _CwtchTextFieldState extends State { filled: true, focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor, width: 3.0)), focusedErrorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor, width: 3.0)), - errorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor, width: 3.0)), errorStyle: TextStyle( color: theme.current().textfieldErrorColor,