-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2afb1d
commit e4b8ceb
Showing
1 changed file
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:threebotlogin/models/farm.dart'; | ||
import 'package:threebotlogin/widgets/farm_node_item.dart'; | ||
|
||
class FarmItemWidget extends StatefulWidget { | ||
const FarmItemWidget({super.key, required this.farm}); | ||
final Farm farm; | ||
|
||
@override | ||
State<FarmItemWidget> createState() => _FarmItemWidgetState(); | ||
} | ||
|
||
class _FarmItemWidgetState extends State<FarmItemWidget> { | ||
final walletAddressController = TextEditingController(); | ||
final tfchainWalletSecretController = TextEditingController(); | ||
final walletNameController = TextEditingController(); | ||
final twinIdController = TextEditingController(); | ||
final farmIdController = TextEditingController(); | ||
|
||
@override | ||
void dispose() { | ||
walletAddressController.dispose(); | ||
tfchainWalletSecretController.dispose(); | ||
walletNameController.dispose(); | ||
twinIdController.dispose(); | ||
farmIdController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
walletAddressController.text = widget.farm.walletAddress; | ||
tfchainWalletSecretController.text = widget.farm.tfchainWalletSecret; | ||
walletNameController.text = widget.farm.walletName; | ||
farmIdController.text = widget.farm.farmId; | ||
twinIdController.text = widget.farm.twinId; | ||
|
||
return ExpansionTile( | ||
title: Text( | ||
widget.farm.name, | ||
style: Theme.of(context).textTheme.titleMedium!.copyWith( | ||
color: Theme.of(context).colorScheme.onBackground, | ||
), | ||
), | ||
childrenPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), | ||
children: [ | ||
ListTile( | ||
title: TextField( | ||
readOnly: true, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium! | ||
.copyWith(color: Theme.of(context).colorScheme.onBackground), | ||
controller: walletAddressController, | ||
decoration: const InputDecoration( | ||
labelText: 'Stellar Payout Address', | ||
)), | ||
subtitle: const Text('This address will be used for payout.'), | ||
trailing: IconButton( | ||
onPressed: () async { | ||
Clipboard.setData( | ||
ClipboardData(text: walletAddressController.text)); | ||
ScaffoldMessenger.of(context).clearSnackBars(); | ||
ScaffoldMessenger.of(context) | ||
.showSnackBar(const SnackBar(content: Text('Copied!'))); | ||
}, | ||
icon: const Icon(Icons.copy)), | ||
), | ||
ListTile( | ||
title: TextField( | ||
readOnly: true, | ||
obscureText: true, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium! | ||
.copyWith(color: Theme.of(context).colorScheme.onBackground), | ||
controller: tfchainWalletSecretController, | ||
decoration: const InputDecoration( | ||
labelText: 'TFChain Secret', | ||
)), | ||
subtitle: const Text( | ||
'You can login into ThreeFold Dashboard using this secret for more farm management.'), | ||
trailing: IconButton( | ||
onPressed: () { | ||
Clipboard.setData( | ||
ClipboardData(text: tfchainWalletSecretController.text)); | ||
ScaffoldMessenger.of(context).clearSnackBars(); | ||
ScaffoldMessenger.of(context) | ||
.showSnackBar(const SnackBar(content: Text('Copied!'))); | ||
}, | ||
icon: const Icon(Icons.copy)), | ||
), | ||
ListTile( | ||
title: TextField( | ||
readOnly: true, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium! | ||
.copyWith(color: Theme.of(context).colorScheme.onBackground), | ||
controller: walletNameController, | ||
decoration: const InputDecoration( | ||
labelText: 'Wallet Name', | ||
)), | ||
), | ||
ListTile( | ||
title: TextField( | ||
readOnly: true, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium! | ||
.copyWith(color: Theme.of(context).colorScheme.onBackground), | ||
controller: twinIdController, | ||
decoration: const InputDecoration( | ||
labelText: 'Twin ID', | ||
)), | ||
), | ||
ListTile( | ||
title: TextField( | ||
readOnly: true, | ||
style: Theme.of(context) | ||
.textTheme | ||
.bodyMedium! | ||
.copyWith(color: Theme.of(context).colorScheme.onBackground), | ||
controller: farmIdController, | ||
decoration: const InputDecoration( | ||
labelText: 'Farm ID', | ||
)), | ||
), | ||
ExpansionTile( | ||
title: const Text('Nodes'), | ||
childrenPadding: const EdgeInsets.only(left: 20), | ||
children: [ | ||
for (final node in widget.farm.nodes) FarmNodeItemWidget(node: node) | ||
], | ||
) | ||
], | ||
); | ||
} | ||
} |