Ran flutter format -l 120 --suppress-analytics lib (#38)
This commit is contained in:
parent
3a37802f4d
commit
9934f226e3
|
@ -8,7 +8,13 @@ import 'package:mobile_nebula/services/utils.dart';
|
|||
/// SimplePage with a form and built in validation and confirmation to discard changes if any are made
|
||||
class FormPage extends StatefulWidget {
|
||||
const FormPage(
|
||||
{Key key, this.title, @required this.child, @required this.onSave, @required this.changed, this.hideSave = false, this.scrollController})
|
||||
{Key key,
|
||||
this.title,
|
||||
@required this.child,
|
||||
@required this.onSave,
|
||||
@required this.changed,
|
||||
this.hideSave = false,
|
||||
this.scrollController})
|
||||
: super(key: key);
|
||||
|
||||
final String title;
|
||||
|
|
|
@ -48,9 +48,7 @@ class IPField extends StatelessWidget {
|
|||
onChanged: onChanged,
|
||||
maxLength: ipOnly ? 15 : null,
|
||||
maxLengthEnforced: ipOnly ? true : false,
|
||||
inputFormatters: ipOnly
|
||||
? [IPTextInputFormatter()]
|
||||
: [FilteringTextInputFormatter.allow(RegExp(r'[^\s]+'))],
|
||||
inputFormatters: ipOnly ? [IPTextInputFormatter()] : [FilteringTextInputFormatter.allow(RegExp(r'[^\s]+'))],
|
||||
textInputAction: this.textInputAction,
|
||||
placeholder: help,
|
||||
));
|
||||
|
@ -68,7 +66,8 @@ class IPTextInputFormatter extends TextInputFormatter {
|
|||
return whitelistedPattern
|
||||
.allMatches(substring)
|
||||
.map<String>((Match match) => match.group(0))
|
||||
.join().replaceAll(RegExp(r','), '.');
|
||||
.join()
|
||||
.replaceAll(RegExp(r','), '.');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -85,15 +84,9 @@ TextEditingValue _selectionAwareTextManipulation(
|
|||
if (selectionStartIndex < 0 || selectionEndIndex < 0) {
|
||||
manipulatedText = substringManipulation(value.text);
|
||||
} else {
|
||||
final String beforeSelection = substringManipulation(
|
||||
value.text.substring(0, selectionStartIndex)
|
||||
);
|
||||
final String inSelection = substringManipulation(
|
||||
value.text.substring(selectionStartIndex, selectionEndIndex)
|
||||
);
|
||||
final String afterSelection = substringManipulation(
|
||||
value.text.substring(selectionEndIndex)
|
||||
);
|
||||
final String beforeSelection = substringManipulation(value.text.substring(0, selectionStartIndex));
|
||||
final String inSelection = substringManipulation(value.text.substring(selectionStartIndex, selectionEndIndex));
|
||||
final String afterSelection = substringManipulation(value.text.substring(selectionEndIndex));
|
||||
manipulatedText = beforeSelection + inSelection + afterSelection;
|
||||
if (value.selection.baseOffset > value.selection.extentOffset) {
|
||||
manipulatedSelection = value.selection.copyWith(
|
||||
|
@ -110,8 +103,6 @@ TextEditingValue _selectionAwareTextManipulation(
|
|||
return TextEditingValue(
|
||||
text: manipulatedText,
|
||||
selection: manipulatedSelection ?? const TextSelection.collapsed(offset: -1),
|
||||
composing: manipulatedText == value.text
|
||||
? value.composing
|
||||
: TextRange.empty,
|
||||
composing: manipulatedText == value.text ? value.composing : TextRange.empty,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -45,14 +45,16 @@ class SimplePage extends StatelessWidget {
|
|||
final VoidCallback onLoading;
|
||||
final RefreshController refreshController;
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget realChild = child;
|
||||
var addScrollbar = this.scrollbar;
|
||||
|
||||
if (scrollable == SimpleScrollable.vertical || scrollable == SimpleScrollable.both) {
|
||||
realChild = SingleChildScrollView(scrollDirection: Axis.vertical, child: realChild, controller: refreshController == null ? scrollController : null);
|
||||
realChild = SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: realChild,
|
||||
controller: refreshController == null ? scrollController : null);
|
||||
addScrollbar = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ import 'package:flutter/material.dart';
|
|||
|
||||
// This is a button that pushes the bare minimum onto you, it doesn't even respect button themes - unless you tell it to
|
||||
class SpecialButton extends StatefulWidget {
|
||||
const SpecialButton({Key key, this.child, this.color, this.onPressed, this.useButtonTheme = false, this.decoration}) : super(key: key);
|
||||
const SpecialButton({Key key, this.child, this.color, this.onPressed, this.useButtonTheme = false, this.decoration})
|
||||
: super(key: key);
|
||||
|
||||
final Widget child;
|
||||
final Color color;
|
||||
|
@ -62,8 +63,7 @@ class _SpecialButtonState extends State<SpecialButton> with SingleTickerProvider
|
|||
child: DefaultTextStyle(style: textStyle, child: Container(child: widget.child, color: widget.color)),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
// Eyeballed values. Feel free to tweak.
|
||||
|
|
|
@ -23,8 +23,8 @@ import 'package:flutter/gestures.dart';
|
|||
const int iOSHorizontalOffset = -2;
|
||||
|
||||
class _TextSpanEditingController extends TextEditingController {
|
||||
_TextSpanEditingController({@required TextSpan textSpan}):
|
||||
assert(textSpan != null),
|
||||
_TextSpanEditingController({@required TextSpan textSpan})
|
||||
: assert(textSpan != null),
|
||||
_textSpan = textSpan,
|
||||
super(text: textSpan.toPlainText());
|
||||
|
||||
|
@ -109,8 +109,7 @@ class _SpecialSelectableTextSelectionGestureDetectorBuilder extends TextSelectio
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (_state.widget.onTap != null)
|
||||
_state.widget.onTap();
|
||||
if (_state.widget.onTap != null) _state.widget.onTap();
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -434,13 +433,17 @@ class SpecialSelectableText extends StatefulWidget {
|
|||
properties.add(DoubleProperty('cursorWidth', cursorWidth, defaultValue: 2.0));
|
||||
properties.add(DiagnosticsProperty<Radius>('cursorRadius', cursorRadius, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<Color>('cursorColor', cursorColor, defaultValue: null));
|
||||
properties.add(FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled'));
|
||||
properties.add(
|
||||
FlagProperty('selectionEnabled', value: selectionEnabled, defaultValue: true, ifFalse: 'selection disabled'));
|
||||
properties.add(DiagnosticsProperty<ScrollPhysics>('scrollPhysics', scrollPhysics, defaultValue: null));
|
||||
properties.add(DiagnosticsProperty<TextHeightBehavior>('textHeightBehavior', textHeightBehavior, defaultValue: null));
|
||||
properties
|
||||
.add(DiagnosticsProperty<TextHeightBehavior>('textHeightBehavior', textHeightBehavior, defaultValue: null));
|
||||
}
|
||||
}
|
||||
|
||||
class _SpecialSelectableTextState extends State<SpecialSelectableText> with AutomaticKeepAliveClientMixin implements TextSelectionGestureDetectorBuilderDelegate {
|
||||
class _SpecialSelectableTextState extends State<SpecialSelectableText>
|
||||
with AutomaticKeepAliveClientMixin
|
||||
implements TextSelectionGestureDetectorBuilderDelegate {
|
||||
EditableTextState get _editableText => editableTextKey.currentState;
|
||||
|
||||
_TextSpanEditingController _controller;
|
||||
|
@ -468,18 +471,14 @@ class _SpecialSelectableTextState extends State<SpecialSelectableText> with Auto
|
|||
void initState() {
|
||||
super.initState();
|
||||
_selectionGestureDetectorBuilder = _SpecialSelectableTextSelectionGestureDetectorBuilder(state: this);
|
||||
_controller = _TextSpanEditingController(
|
||||
textSpan: widget.textSpan ?? TextSpan(text: widget.data)
|
||||
);
|
||||
_controller = _TextSpanEditingController(textSpan: widget.textSpan ?? TextSpan(text: widget.data));
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(SpecialSelectableText oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.data != oldWidget.data || widget.textSpan != oldWidget.textSpan) {
|
||||
_controller = _TextSpanEditingController(
|
||||
textSpan: widget.textSpan ?? TextSpan(text: widget.data)
|
||||
);
|
||||
_controller = _TextSpanEditingController(textSpan: widget.textSpan ?? TextSpan(text: widget.data));
|
||||
}
|
||||
if (_effectiveFocusNode.hasFocus && _controller.selection.isCollapsed) {
|
||||
_showSelectionHandles = false;
|
||||
|
@ -525,20 +524,15 @@ class _SpecialSelectableTextState extends State<SpecialSelectableText> with Auto
|
|||
bool _shouldShowSelectionHandles(SelectionChangedCause cause) {
|
||||
// When the text field is activated by something that doesn't trigger the
|
||||
// selection overlay, we shouldn't show the handles either.
|
||||
if (!_selectionGestureDetectorBuilder.shouldShowSelectionToolbar)
|
||||
return false;
|
||||
if (!_selectionGestureDetectorBuilder.shouldShowSelectionToolbar) return false;
|
||||
|
||||
if (_controller.selection.isCollapsed)
|
||||
return false;
|
||||
if (_controller.selection.isCollapsed) return false;
|
||||
|
||||
if (cause == SelectionChangedCause.keyboard)
|
||||
return false;
|
||||
if (cause == SelectionChangedCause.keyboard) return false;
|
||||
|
||||
if (cause == SelectionChangedCause.longPress)
|
||||
return true;
|
||||
if (cause == SelectionChangedCause.longPress) return true;
|
||||
|
||||
if (_controller.text.isNotEmpty)
|
||||
return true;
|
||||
if (_controller.text.isNotEmpty) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -555,7 +549,8 @@ class _SpecialSelectableTextState extends State<SpecialSelectableText> with Auto
|
|||
assert(debugCheckHasMediaQuery(context));
|
||||
assert(debugCheckHasDirectionality(context));
|
||||
assert(
|
||||
!(widget.style != null && widget.style.inherit == false &&
|
||||
!(widget.style != null &&
|
||||
widget.style.inherit == false &&
|
||||
(widget.style.fontSize == null || widget.style.textBaseline == null)),
|
||||
'inherit false style must supply fontSize and textBaseline',
|
||||
);
|
||||
|
@ -596,8 +591,7 @@ class _SpecialSelectableTextState extends State<SpecialSelectableText> with Auto
|
|||
|
||||
final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context);
|
||||
TextStyle effectiveTextStyle = widget.style;
|
||||
if (widget.style == null || widget.style.inherit)
|
||||
effectiveTextStyle = defaultTextStyle.style.merge(widget.style);
|
||||
if (widget.style == null || widget.style.inherit) effectiveTextStyle = defaultTextStyle.style.merge(widget.style);
|
||||
if (MediaQuery.boldTextOverride(context))
|
||||
effectiveTextStyle = effectiveTextStyle.merge(const TextStyle(fontWeight: FontWeight.bold));
|
||||
final Widget child = RepaintBoundary(
|
||||
|
@ -653,8 +647,7 @@ class _SpecialSelectableTextState extends State<SpecialSelectableText> with Auto
|
|||
focusNode: _keyFocusNode,
|
||||
onKey: _onKey,
|
||||
child: child,
|
||||
)
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,6 @@ class Site {
|
|||
});
|
||||
|
||||
return hosts;
|
||||
|
||||
} on PlatformException catch (err) {
|
||||
//TODO: fix this message
|
||||
throw err.details ?? err.message ?? err.toString();
|
||||
|
@ -239,7 +238,6 @@ class Site {
|
|||
});
|
||||
|
||||
return hosts;
|
||||
|
||||
} on PlatformException catch (err) {
|
||||
throw err.details ?? err.message ?? err.toString();
|
||||
} catch (err) {
|
||||
|
@ -251,7 +249,6 @@ class Site {
|
|||
try {
|
||||
var res = await Future.wait([this.listHostmap(), this.listPendingHostmap()]);
|
||||
return {"active": res[0], "pending": res[1]};
|
||||
|
||||
} on PlatformException catch (err) {
|
||||
throw err.details ?? err.message ?? err.toString();
|
||||
} catch (err) {
|
||||
|
@ -265,14 +262,14 @@ class Site {
|
|||
|
||||
Future<HostInfo> getHostInfo(String vpnIp, bool pending) async {
|
||||
try {
|
||||
var ret = await platform.invokeMethod("active.getHostInfo", <String, dynamic>{"id": id, "vpnIp": vpnIp, "pending": pending});
|
||||
var ret = await platform
|
||||
.invokeMethod("active.getHostInfo", <String, dynamic>{"id": id, "vpnIp": vpnIp, "pending": pending});
|
||||
final h = jsonDecode(ret);
|
||||
if (h == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return HostInfo.fromJson(h);
|
||||
|
||||
} on PlatformException catch (err) {
|
||||
throw err.details ?? err.message ?? err.toString();
|
||||
} catch (err) {
|
||||
|
@ -282,14 +279,14 @@ class Site {
|
|||
|
||||
Future<HostInfo> setRemoteForTunnel(String vpnIp, String addr) async {
|
||||
try {
|
||||
var ret = await platform.invokeMethod("active.setRemoteForTunnel", <String, dynamic>{"id": id, "vpnIp": vpnIp, "addr": addr});
|
||||
var ret = await platform
|
||||
.invokeMethod("active.setRemoteForTunnel", <String, dynamic>{"id": id, "vpnIp": vpnIp, "addr": addr});
|
||||
final h = jsonDecode(ret);
|
||||
if (h == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return HostInfo.fromJson(h);
|
||||
|
||||
} on PlatformException catch (err) {
|
||||
throw err.details ?? err.message ?? err.toString();
|
||||
} catch (err) {
|
||||
|
@ -300,7 +297,6 @@ class Site {
|
|||
Future<bool> closeTunnel(String vpnIp) async {
|
||||
try {
|
||||
return await platform.invokeMethod("active.closeTunnel", <String, dynamic>{"id": id, "vpnIp": vpnIp});
|
||||
|
||||
} on PlatformException catch (err) {
|
||||
throw err.details ?? err.message ?? err.toString();
|
||||
} catch (err) {
|
||||
|
|
|
@ -48,18 +48,32 @@ class _AboutScreenState extends State<AboutScreen> {
|
|||
title: 'About',
|
||||
child: Column(children: [
|
||||
ConfigSection(children: <Widget>[
|
||||
ConfigItem(label: Text('App version'), labelWidth: 150, content: _buildText('${packageInfo.version}-${packageInfo.buildNumber} (sha: $gitSha)')),
|
||||
ConfigItem(label: Text('Nebula version'), labelWidth: 150, content: _buildText('$nebulaVersion ($goVersion)')),
|
||||
ConfigItem(label: Text('Flutter version'), labelWidth: 150, content: _buildText(flutterVersion['frameworkVersion'])),
|
||||
ConfigItem(label: Text('Dart version'), labelWidth: 150, content: _buildText(flutterVersion['dartSdkVersion'])),
|
||||
ConfigItem(
|
||||
label: Text('App version'),
|
||||
labelWidth: 150,
|
||||
content: _buildText('${packageInfo.version}-${packageInfo.buildNumber} (sha: $gitSha)')),
|
||||
ConfigItem(
|
||||
label: Text('Nebula version'), labelWidth: 150, content: _buildText('$nebulaVersion ($goVersion)')),
|
||||
ConfigItem(
|
||||
label: Text('Flutter version'), labelWidth: 150, content: _buildText(flutterVersion['frameworkVersion'])),
|
||||
ConfigItem(
|
||||
label: Text('Dart version'), labelWidth: 150, content: _buildText(flutterVersion['dartSdkVersion'])),
|
||||
]),
|
||||
ConfigSection(children: <Widget>[
|
||||
//TODO: wire up these other pages
|
||||
// ConfigPageItem(label: Text('Changelog'), labelWidth: 300, onPressed: () => Utils.launchUrl('https://defined.net/mobile/changelog', context)),
|
||||
ConfigPageItem(label: Text('Privacy policy'), labelWidth: 300, onPressed: () => Utils.launchUrl('https://defined.net/privacy-policy', context)),
|
||||
ConfigPageItem(
|
||||
label: Text('Privacy policy'),
|
||||
labelWidth: 300,
|
||||
onPressed: () => Utils.launchUrl('https://defined.net/privacy-policy', context)),
|
||||
// ConfigPageItem(label: Text('Licenses'), labelWidth: 300, onPressed: () => Utils.launchUrl('https://defined.net/mobile/license', context)),
|
||||
]),
|
||||
Padding(padding: EdgeInsets.only(top: 20), child: Text('Copyright © 2020 Defined Networking, Inc', textAlign: TextAlign.center,)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: Text(
|
||||
'Copyright © 2020 Defined Networking, Inc',
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ class _MainScreenState extends State<MainScreen> {
|
|||
Widget _buildNoSites() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(child: Column(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8.0, 0, 8.0),
|
||||
|
@ -146,10 +147,7 @@ class _MainScreenState extends State<MainScreen> {
|
|||
}
|
||||
|
||||
// The theme here is to remove the hardcoded canvas border reordering forces on us
|
||||
return Theme(
|
||||
data: Theme.of(context).copyWith(canvasColor: Colors.transparent),
|
||||
child: child
|
||||
);
|
||||
return Theme(data: Theme.of(context).copyWith(canvasColor: Colors.transparent), child: child);
|
||||
}
|
||||
|
||||
Widget _debugSave() {
|
||||
|
@ -176,12 +174,13 @@ mUOcsdFcCZiXrj7ryQIG1+WfqA46w71A/lV4nAc=
|
|||
name: "DEBUG TEST",
|
||||
id: uuid.v4(),
|
||||
staticHostmap: {
|
||||
"10.1.0.1": StaticHost(lighthouse: true, destinations: [IPAndPort(ip: '10.1.1.53', port: 4242), IPAndPort(ip: '1::1', port: 4242)])
|
||||
"10.1.0.1": StaticHost(
|
||||
lighthouse: true,
|
||||
destinations: [IPAndPort(ip: '10.1.1.53', port: 4242), IPAndPort(ip: '1::1', port: 4242)])
|
||||
},
|
||||
ca: [CertificateInfo.debug(rawCert: ca)],
|
||||
certInfo: CertificateInfo.debug(rawCert: cert),
|
||||
unsafeRoutes: [UnsafeRoute(route: '10.3.3.3/32', via: '10.1.0.1')]
|
||||
);
|
||||
unsafeRoutes: [UnsafeRoute(route: '10.3.3.3/32', via: '10.1.0.1')]);
|
||||
|
||||
s.key = '''-----BEGIN NEBULA X25519 PRIVATE KEY-----
|
||||
rmXnR1yvDZi1VPVmnNVY8NMsQpEpbbYlq7rul+ByQvg=
|
||||
|
@ -239,7 +238,8 @@ rmXnR1yvDZi1VPVmnNVY8NMsQpEpbbYlq7rul+ByQvg=
|
|||
}
|
||||
|
||||
if (hasErrors) {
|
||||
Utils.popError(context, "Site Error(s)", "1 or more sites have errors and need your attention, problem sites have a red border.");
|
||||
Utils.popError(context, "Site Error(s)",
|
||||
"1 or more sites have errors and need your attention, problem sites have a red border.");
|
||||
}
|
||||
|
||||
sites.sort((a, b) {
|
||||
|
|
|
@ -62,7 +62,6 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
|
|||
}
|
||||
}
|
||||
setState(() {});
|
||||
|
||||
}, onError: (err) {
|
||||
setState(() {});
|
||||
Utils.popError(context, "Error", err);
|
||||
|
@ -111,7 +110,8 @@ class _SiteDetailScreenState extends State<SiteDetailScreen> {
|
|||
List<Widget> items = [];
|
||||
site.errors.forEach((error) {
|
||||
items.add(ConfigItem(
|
||||
labelWidth: 0, content: Padding(padding: EdgeInsets.symmetric(vertical: 10), child: SpecialSelectableText(error))));
|
||||
labelWidth: 0,
|
||||
content: Padding(padding: EdgeInsets.symmetric(vertical: 10), child: SpecialSelectableText(error))));
|
||||
});
|
||||
|
||||
return ConfigSection(
|
||||
|
|
|
@ -54,7 +54,10 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
refreshController.loadComplete();
|
||||
},
|
||||
refreshController: refreshController,
|
||||
child: Container(padding: EdgeInsets.all(5), constraints: logBoxConstraints(context), child: SpecialSelectableText(logs.trim(), style: TextStyle(fontFamily: 'RobotoMono', fontSize: 14))),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
constraints: logBoxConstraints(context),
|
||||
child: SpecialSelectableText(logs.trim(), style: TextStyle(fontFamily: 'RobotoMono', fontSize: 14))),
|
||||
bottomBar: _buildBottomBar(),
|
||||
);
|
||||
}
|
||||
|
@ -78,7 +81,10 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
padding: padding,
|
||||
icon: Icon(context.platformIcons.share, size: 30),
|
||||
onPressed: () {
|
||||
Share.shareFile(title: '${widget.site.name} logs', filePath: widget.site.logFile, filename: '${widget.site.name}.log');
|
||||
Share.shareFile(
|
||||
title: '${widget.site.name} logs',
|
||||
filePath: widget.site.logFile,
|
||||
filename: '${widget.site.name}.log');
|
||||
},
|
||||
)),
|
||||
Expanded(
|
||||
|
@ -94,7 +100,8 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
padding: padding,
|
||||
icon: Icon(context.platformIcons.downArrow, size: 30),
|
||||
onPressed: () async {
|
||||
controller.animateTo(controller.position.maxScrollExtent, duration: const Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
|
||||
controller.animateTo(controller.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
|
||||
},
|
||||
)),
|
||||
]));
|
||||
|
|
|
@ -72,9 +72,7 @@ class _AddCertificateScreenState extends State<AddCertificateScreen> {
|
|||
items.addAll(_buildShare());
|
||||
items.addAll(_buildLoadCert());
|
||||
|
||||
return SimplePage(
|
||||
title: 'Certificate',
|
||||
child: Column(children: items));
|
||||
return SimplePage(title: 'Certificate', child: Column(children: items));
|
||||
}
|
||||
|
||||
_generateKeys() async {
|
||||
|
@ -215,8 +213,8 @@ class _AddCertificateScreenState extends State<AddCertificateScreen> {
|
|||
if (certs.length > 0) {
|
||||
var tryCertInfo = CertificateInfo.fromJson(certs.first);
|
||||
if (tryCertInfo.cert.details.isCa) {
|
||||
return Utils.popError(context, 'Error loading certificate content', 'A certificate authority is not appropriate for a client certificate.');
|
||||
|
||||
return Utils.popError(context, 'Error loading certificate content',
|
||||
'A certificate authority is not appropriate for a client certificate.');
|
||||
} else if (!tryCertInfo.validity.valid) {
|
||||
return Utils.popError(context, 'Certificate was invalid', tryCertInfo.validity.reason);
|
||||
}
|
||||
|
@ -232,7 +230,9 @@ class _AddCertificateScreenState extends State<AddCertificateScreen> {
|
|||
|
||||
// We have a cert, pop the details screen where they can hit save
|
||||
Utils.openPage(context, (context) {
|
||||
return CertificateDetailsScreen(certInfo: tryCertInfo, onSave: () {
|
||||
return CertificateDetailsScreen(
|
||||
certInfo: tryCertInfo,
|
||||
onSave: () {
|
||||
Navigator.pop(context);
|
||||
widget.onSave(CertificateResult(certInfo: tryCertInfo, key: privKey));
|
||||
});
|
||||
|
|
|
@ -153,7 +153,9 @@ class _AdvancedScreenState extends State<AdvancedScreen> {
|
|||
content: Text(Utils.itemCountFormat(settings.unsafeRoutes.length), textAlign: TextAlign.end),
|
||||
onPressed: () {
|
||||
Utils.openPage(context, (context) {
|
||||
return UnsafeRoutesScreen(unsafeRoutes: settings.unsafeRoutes, onSave: (routes) {
|
||||
return UnsafeRoutesScreen(
|
||||
unsafeRoutes: settings.unsafeRoutes,
|
||||
onSave: (routes) {
|
||||
setState(() {
|
||||
settings.unsafeRoutes = routes;
|
||||
changed = true;
|
||||
|
|
|
@ -201,7 +201,6 @@ class _CAListScreenState extends State<CAListScreen> {
|
|||
setState(() {});
|
||||
}
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
return Utils.popError(context, 'Failed to load CA file', err.toString());
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ import 'package:mobile_nebula/services/utils.dart';
|
|||
|
||||
/// Displays the details of a CertificateInfo object. Respects incomplete objects (missing validity or rawCert)
|
||||
class CertificateDetailsScreen extends StatefulWidget {
|
||||
const CertificateDetailsScreen({Key key, this.certInfo, this.onDelete, this.onSave, this.onReplace}) : super(key: key);
|
||||
const CertificateDetailsScreen({Key key, this.certInfo, this.onDelete, this.onSave, this.onReplace})
|
||||
: super(key: key);
|
||||
|
||||
final CertificateInfo certInfo;
|
||||
|
||||
|
@ -78,8 +79,7 @@ class _CertificateDetailsScreenState extends State<CertificateDetailsScreen> {
|
|||
return ConfigSection(children: <Widget>[
|
||||
ConfigItem(label: Text('Name'), content: SpecialSelectableText(certInfo.cert.details.name)),
|
||||
ConfigItem(
|
||||
label: Text('Type'),
|
||||
content: Text(certInfo.cert.details.isCa ? 'CA certificate' : 'Client certificate')),
|
||||
label: Text('Type'), content: Text(certInfo.cert.details.isCa ? 'CA certificate' : 'Client certificate')),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -106,18 +106,17 @@ class _CertificateDetailsScreenState extends State<CertificateDetailsScreen> {
|
|||
Widget _buildFilters() {
|
||||
List<Widget> items = [];
|
||||
if (certInfo.cert.details.groups.length > 0) {
|
||||
items.add(ConfigItem(
|
||||
label: Text('Groups'), content: SpecialSelectableText(certInfo.cert.details.groups.join(', '))));
|
||||
items.add(
|
||||
ConfigItem(label: Text('Groups'), content: SpecialSelectableText(certInfo.cert.details.groups.join(', '))));
|
||||
}
|
||||
|
||||
if (certInfo.cert.details.ips.length > 0) {
|
||||
items
|
||||
.add(ConfigItem(label: Text('IPs'), content: SpecialSelectableText(certInfo.cert.details.ips.join(', '))));
|
||||
items.add(ConfigItem(label: Text('IPs'), content: SpecialSelectableText(certInfo.cert.details.ips.join(', '))));
|
||||
}
|
||||
|
||||
if (certInfo.cert.details.subnets.length > 0) {
|
||||
items.add(ConfigItem(
|
||||
label: Text('Subnets'), content: SpecialSelectableText(certInfo.cert.details.subnets.join(', '))));
|
||||
items.add(
|
||||
ConfigItem(label: Text('Subnets'), content: SpecialSelectableText(certInfo.cert.details.subnets.join(', '))));
|
||||
}
|
||||
|
||||
return items.length > 0
|
||||
|
@ -141,8 +140,8 @@ class _CertificateDetailsScreenState extends State<CertificateDetailsScreen> {
|
|||
certInfo.rawCert != null
|
||||
? ConfigItem(
|
||||
label: Text('PEM Format'),
|
||||
content: SpecialSelectableText(certInfo.rawCert,
|
||||
style: TextStyle(fontFamily: 'RobotoMono', fontSize: 14)),
|
||||
content:
|
||||
SpecialSelectableText(certInfo.rawCert, style: TextStyle(fontFamily: 'RobotoMono', fontSize: 14)),
|
||||
crossAxisAlignment: CrossAxisAlignment.start)
|
||||
: Container(),
|
||||
],
|
||||
|
@ -163,15 +162,15 @@ class _CertificateDetailsScreenState extends State<CertificateDetailsScreen> {
|
|||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
onPressed: () {
|
||||
Utils.openPage(context, (context) {
|
||||
return AddCertificateScreen(
|
||||
onReplace: (result) {
|
||||
return AddCertificateScreen(onReplace: (result) {
|
||||
setState(() {
|
||||
changed = true;
|
||||
certResult = result;
|
||||
certInfo = certResult.certInfo;
|
||||
});
|
||||
// Slam the page back to the top
|
||||
controller.animateTo(0, duration: const Duration(milliseconds: 10), curve: Curves.linearToEaseOut);
|
||||
controller.animateTo(0,
|
||||
duration: const Duration(milliseconds: 10), curve: Curves.linearToEaseOut);
|
||||
});
|
||||
});
|
||||
})));
|
||||
|
|
|
@ -147,12 +147,10 @@ class _SiteConfigScreenState extends State<SiteConfigScreen> {
|
|||
site.certInfo = result.certInfo;
|
||||
site.key = result.key;
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return AddCertificateScreen(
|
||||
onSave: (result) {
|
||||
return AddCertificateScreen(onSave: (result) {
|
||||
setState(() {
|
||||
changed = true;
|
||||
site.certInfo = result.certInfo;
|
||||
|
|
|
@ -83,7 +83,9 @@ class _UnsafeRoutesScreenState extends State<UnsafeRoutesScreen> {
|
|||
content: Text('Add a new route'),
|
||||
onPressed: () {
|
||||
Utils.openPage(context, (context) {
|
||||
return UnsafeRouteScreen(route: UnsafeRoute(), onSave: (route) {
|
||||
return UnsafeRouteScreen(
|
||||
route: UnsafeRoute(),
|
||||
onSave: (route) {
|
||||
setState(() {
|
||||
changed = true;
|
||||
unsafeRoutes[UniqueKey()] = route;
|
||||
|
|
|
@ -44,8 +44,7 @@ class Share {
|
|||
throw FlutterError('FilePath cannot be null');
|
||||
}
|
||||
|
||||
final bool success =
|
||||
await _channel.invokeMethod('shareFile', <String, dynamic>{
|
||||
final bool success = await _channel.invokeMethod('shareFile', <String, dynamic>{
|
||||
'title': title,
|
||||
'filePath': filePath,
|
||||
'filename': filename,
|
||||
|
|
|
@ -7,14 +7,18 @@ bool ipValidator(String str, bool enableIPV6) {
|
|||
}
|
||||
|
||||
switch (ia.type) {
|
||||
case InternetAddressType.IPv6: {
|
||||
case InternetAddressType.IPv6:
|
||||
{
|
||||
if (enableIPV6) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case InternetAddressType.IPv4: { return true; }
|
||||
case InternetAddressType.IPv4:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue