flutter format
continuous-integration/drone/pr Build is pending Details

This commit is contained in:
Dan Ballard 2021-12-15 17:29:27 -05:00
parent b29bb1e4dc
commit abf4d79e80
30 changed files with 322 additions and 368 deletions

View File

@ -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...

View File

@ -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,

View File

@ -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),
);

View File

@ -86,10 +86,10 @@ class _AddEditServerViewState extends State<AddEditServerView> {
// 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<AddEditServerView> {
height: 20,
),
Text(AppLocalizations.of(context)!.serverMetricsLabel, style: Provider.of<FlwtchState>(context).biggerFont),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row( crossAxisAlignment: CrossAxisAlignment.start, children: [
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: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(AppLocalizations.of(context)!.serverConnectionsLabel),
]),
Text(serverInfoState.connections.toString())
]),
])),
// ***** Password *****

View File

@ -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;
}

View File

@ -314,8 +314,7 @@ class _MessageViewState extends State<MessageView> {
children = [composeBox];
}
return Container(
color: Provider.of<Settings>(context).theme.backgroundMainColor, child: Column(mainAxisSize: MainAxisSize.min, children: children));
return Container(color: Provider.of<Settings>(context).theme.backgroundMainColor, child: Column(mainAxisSize: MainAxisSize.min, children: children));
}
// Send the message if enter is pressed without the shift key...

View File

@ -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<ProfileServersView> {
@override
void dispose() {
super.dispose();
@ -25,9 +23,10 @@ class _ProfileServersView extends State<ProfileServersView> {
@override
Widget build(BuildContext context) {
var knownServers = Provider.of<ProfileInfoState>(context).serverList.servers.map<String>((RemoteServerInfoState remoteServer) { return remoteServer.onion + ".onion"; }).toSet();
var importServerList = Provider.of<ServerListState>(context).servers.where((server) => !knownServers.contains(server.onion) ).map<DropdownMenuItem<String>>((ServerInfoState serverInfo) {
var knownServers = Provider.of<ProfileInfoState>(context).serverList.servers.map<String>((RemoteServerInfoState remoteServer) {
return remoteServer.onion + ".onion";
}).toSet();
var importServerList = Provider.of<ServerListState>(context).servers.where((server) => !knownServers.contains(server.onion)).map<DropdownMenuItem<String>>((ServerInfoState serverInfo) {
return DropdownMenuItem<String>(
value: serverInfo.onion,
child: Text(
@ -37,20 +36,17 @@ class _ProfileServersView extends State<ProfileServersView> {
);
}).toList();
importServerList.insert(0, DropdownMenuItem<String>(
value: "",
child: Text(AppLocalizations.of(context)!.importLocalServerSelectText)));
importServerList.insert(0, DropdownMenuItem<String>(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<ProfileInfoState>(builder: (context, profile, child) {
body: Consumer<ProfileInfoState>(
builder: (context, profile, child) {
ProfileServerListState servers = profile.serverList;
final tiles = servers.servers.map((RemoteServerInfoState server) {
final tiles = servers.servers.map(
(RemoteServerInfoState server) {
return ChangeNotifierProvider<RemoteServerInfoState>.value(
value: server,
builder: (context, child) => RepaintBoundary(child: RemoteServerRow()),
@ -63,20 +59,19 @@ class _ProfileServersView extends State<ProfileServersView> {
tiles: tiles,
).toList();
final importCard = Card( child: ListTile(
final importCard = Card(
child: ListTile(
title: Text(AppLocalizations.of(context)!.importLocalServerLabel),
leading: Icon(CwtchIcons.add_circle_24px , color: Provider.of<Settings>(context).current().mainTextColor),
leading: Icon(CwtchIcons.add_circle_24px, color: Provider.of<Settings>(context).current().mainTextColor),
trailing: DropdownButton(
onChanged: (String? importServer) {
if (importServer!.isNotEmpty) {
var server = Provider.of<ServerListState>(context).getServer(importServer)!;
showImportConfirm(context, profile.onion, server.onion, server.description, server.serverBundle);
}
},
value: "",
items: importServerList,
)));
return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
@ -84,16 +79,11 @@ class _ProfileServersView extends State<ProfileServersView> {
isAlwaysShown: true,
child: SingleChildScrollView(
clipBehavior: Clip.antiAlias,
child:
Container(
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 )
]))));});
child: Column(children: [if (importServerList.length > 1) importCard, Column(children: divided)]))));
});
return ListView(children: divided);
},
@ -102,7 +92,7 @@ class _ProfileServersView extends State<ProfileServersView> {
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<ProfileServersView> {
Future.delayed(const Duration(milliseconds: 500), () {
var profile = Provider.of<ProfileInfoState>(context);
if (profile.serverList.getServer(serverHandle) != null) {
profile.serverList.getServer(serverHandle)?.updateDescription(
serverDesc);
profile.serverList.getServer(serverHandle)?.updateDescription(serverDesc);
Provider
.of<FlwtchState>(context, listen: false)
.cwtch
.SetConversationAttribute(profile.onion, profile.serverList
.getServer(serverHandle)
!.identifier, "server.description", serverDesc);
Provider.of<FlwtchState>(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<ProfileServersView> {
},
);
}
}

View File

@ -50,9 +50,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
Widget build(BuildContext context) {
return Consumer3<ProfileInfoState, RemoteServerInfoState, Settings>(builder: (context, profile, serverInfoState, settings, child) {
return Scaffold(
appBar: AppBar(
title: Text(ctrlrDesc.text.isNotEmpty ? ctrlrDesc.text : 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),
@ -64,9 +62,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
SizedBox(
height: 20,
),
SelectableText(
serverInfoState.onion
),
SelectableText(serverInfoState.onion),
// Description
SizedBox(
@ -93,15 +89,18 @@ class _RemoteServerViewState extends State<RemoteServerView> {
height: 20,
),
Padding(padding: EdgeInsets.all(8), child: Text( AppLocalizations.of(context)!.groupsOnThisServerLabel),),
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) {
final tiles = serverInfoState.groups.map(
(ContactInfoState group) {
return ChangeNotifierProvider<ContactInfoState>.value(
value: group,
builder: (context, child) => RepaintBoundary(child: _buildGroupRow(group)), // ServerRow()),
@ -126,8 +125,7 @@ class _RemoteServerViewState extends State<RemoteServerView> {
Widget _buildGroupRow(ContactInfoState group) {
return Padding(
padding: const EdgeInsets.all(6.0), //border size
child: Column(
children: [
child: Column(children: [
Text(
group.nickname,
style: Provider.of<FlwtchState>(context).biggerFont.apply(color: Provider.of<Settings>(context).theme.portraitOnlineBorderColor),
@ -143,9 +141,6 @@ class _RemoteServerViewState extends State<RemoteServerView> {
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Provider.of<Settings>(context).theme.portraitOnlineBorderColor),
)))
])
);
]));
}
}

View File

@ -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<Settings>(context).theme.mainTextColor : Provider.of<Settings>(context).theme.textfieldErrorColor)),
style: TextStyle(fontSize: 16.0, color: appState.appError == "" ? Provider.of<Settings>(context).theme.mainTextColor : Provider.of<Settings>(context).theme.textfieldErrorColor)),
),
Image(image: AssetImage("assets/Open_Privacy_Logo_lightoutline.png")),
])),

View File

@ -115,8 +115,7 @@ class FileBubbleState extends State<FileBubble> {
child: Container(
decoration: BoxDecoration(
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor,
border:
Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1),
border: Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(borderRadiousEh),
topRight: Radius.circular(borderRadiousEh),

View File

@ -97,8 +97,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
child: Container(
decoration: BoxDecoration(
color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor,
border:
Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1),
border: Border.all(color: fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor, width: 1),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(borderRadiousEh),
topRight: Radius.circular(borderRadiousEh),

View File

@ -95,9 +95,7 @@ class MessageBubbleState extends State<MessageBubble> {
child: Container(
child: Container(
decoration: BoxDecoration(
color: error
? malformedColor
: (fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor),
color: error ? malformedColor : (fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor),
border: Border.all(
color: error
? malformedColor

View File

@ -25,8 +25,7 @@ class _MessageBubbleDecoration extends State<MessageBubbleDecoration> {
mainAxisSize: MainAxisSize.min,
children: [
Text(widget.prettyDate,
style:
TextStyle(fontSize: 9.0, color: widget.fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor),
style: TextStyle(fontSize: 9.0, color: widget.fromMe ? Provider.of<Settings>(context).theme.messageFromMeTextColor : Provider.of<Settings>(context).theme.messageFromOtherTextColor),
textAlign: widget.fromMe ? TextAlign.right : TextAlign.left),
!widget.fromMe
? SizedBox(width: 1, height: 1)

View File

@ -90,9 +90,7 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
child: Container(
child: Container(
decoration: BoxDecoration(
color: error
? malformedColor
: (fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor),
color: error ? malformedColor : (fromMe ? Provider.of<Settings>(context).theme.messageFromMeBackgroundColor : Provider.of<Settings>(context).theme.messageFromOtherBackgroundColor),
border: Border.all(
color: error
? malformedColor

View File

@ -25,28 +25,25 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
var server = Provider.of<RemoteServerInfoState>(context);
var description = server.description.isNotEmpty ? server.description : server.onion;
var running = server.status == "Synced";
return Consumer<ProfileInfoState>(
builder: (context, profile, child) {
return Card(clipBehavior: Clip.antiAlias,
return Consumer<ProfileInfoState>(builder: (context, profile, child) {
return Card(
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.all(0.0),
child: InkWell(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Padding(
padding: const EdgeInsets.all(6.0), //border size
child: Icon(CwtchIcons.dns_24px,
color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor,
size: 64)
),
color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor, size: 64)),
Expanded(
child: Column(
children: [
Text(
description,
semanticsLabel: description,
style: Provider.of<FlwtchState>(context).biggerFont.apply(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
style: Provider.of<FlwtchState>(context)
.biggerFont
.apply(color: running ? Provider.of<Settings>(context).theme.portraitOnlineBorderColor : Provider.of<Settings>(context).theme.portraitOfflineBorderColor),
softWrap: true,
overflow: TextOverflow.ellipsis,
),
@ -61,7 +58,6 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
)))
],
)),
]),
onTap: () {
Navigator.of(context).push(MaterialPageRoute<void>(
@ -72,7 +68,7 @@ class _RemoteServerRowState extends State<RemoteServerRow> {
child: RemoteServerView(),
);
}));
}
));});
}));
});
}
}

View File

@ -76,8 +76,7 @@ class _ServerRowState extends State<ServerRow> {
]),
onTap: () {
_pushEditServer(server);
}
));
}));
}
void _pushEditServer(ServerInfoState server) {

View File

@ -47,7 +47,6 @@ class _CwtchTextFieldState extends State<CwtchTextField> {
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,