Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 37 additions & 32 deletions app/lib/widgets/farm_node_item.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:threebotlogin/helpers/country_code.dart';
import 'package:threebotlogin/main.dart';
import 'package:threebotlogin/models/farm.dart';
import 'package:flag/flag.dart';

Expand Down Expand Up @@ -78,30 +79,38 @@ class _FarmNodeItemWidgetState extends State<FarmNodeItemWidget> {
required Color borderColor,
required Color textColor,
}) {
return Container(
padding: const EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4),
decoration: BoxDecoration(
border: Border.all(
color: borderColor,
return Flexible(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
border: Border.all(
color: borderColor,
),
borderRadius: BorderRadius.circular(20),
),
child: Text(
label,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: textColor,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
borderRadius: BorderRadius.circular(20),
),
child: Text(
label,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: textColor,
),
),
);
}

@override
Widget build(BuildContext context) {
String? countryCode = countryNameToCode[widget.node.country];
final statusColor = widget.node.status == NodeStatus.Up
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.error;

late Color statusColor;
if(widget.node.status == NodeStatus.Up) {
statusColor = Theme.of(context).colorScheme.primary;
} else if (widget.node.status == NodeStatus.Down) {
statusColor = Theme.of(context).colorScheme.error;
} else {
statusColor = Theme.of(context).colorScheme.warning;
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 10.0),
child: Row(
Expand Down Expand Up @@ -130,23 +139,19 @@ class _FarmNodeItemWidgetState extends State<FarmNodeItemWidget> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 2,
child: Text(
'Node ID: ${widget.node.nodeId}',
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
Text(
'Node ID: ${widget.node.nodeId}',
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
),
const SizedBox(width: 8.0),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 8.0),

// Chips in their own row with proper spacing
Row(
children: [
// Country Chip
_buildChip(
label: widget.node.country!,
Expand All @@ -163,7 +168,7 @@ class _FarmNodeItemWidgetState extends State<FarmNodeItemWidget> {
),
],
),
const SizedBox(height: 6.0),
const SizedBox(height: 8.0),
Text(
'Farm: ${widget.farmName}',
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
Expand Down