3
0
Fork 0
trifid_mobile/lib/components/SiteItem.dart

52 lines
2.0 KiB
Dart
Raw Normal View History

2020-07-27 20:43:58 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mobile_nebula/components/SpecialButton.dart';
import 'package:mobile_nebula/models/Site.dart';
import 'package:mobile_nebula/services/utils.dart';
class SiteItem extends StatelessWidget {
const SiteItem({Key key, this.site, this.onPressed}) : super(key: key);
final Site site;
final onPressed;
@override
Widget build(BuildContext context) {
final borderColor = site.errors.length > 0
? CupertinoColors.systemRed.resolveFrom(context)
: site.connected
? CupertinoColors.systemGreen.resolveFrom(context)
: CupertinoColors.systemGrey2.resolveFrom(context);
final border = BorderSide(color: borderColor, width: 10);
return Container(
margin: EdgeInsets.symmetric(vertical: 6),
decoration: BoxDecoration(border: Border(left: border)),
child: _buildContent(context));
}
Widget _buildContent(BuildContext context) {
final border = BorderSide(color: Utils.configSectionBorder(context));
var ip = "Error";
2021-04-29 21:39:02 +00:00
if (site.primaryCertInfo.cert != null && site.primaryCertInfo.cert.details.ips.length > 0) {
ip = site.primaryCertInfo.cert.details.ips[0];
2020-07-27 20:43:58 +00:00
}
return SpecialButton(
decoration:
BoxDecoration(border: Border(top: border, bottom: border), color: Utils.configItemBackground(context)),
onPressed: onPressed,
child: Padding(
padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(site.name, style: TextStyle(fontWeight: FontWeight.bold)),
Expanded(child: Text(ip, textAlign: TextAlign.end)),
Padding(padding: EdgeInsets.only(right: 10)),
Icon(CupertinoIcons.forward, color: CupertinoColors.placeholderText.resolveFrom(context), size: 18)
],
)));
}
}