@@ -14,10 +14,49 @@ class CouncilScreen extends StatefulWidget {
1414class _CouncilScreenState extends State <CouncilScreen > {
1515 final urlController = TextEditingController ();
1616 String ? errorMessage;
17+ String ? selectedNetwork = '' ;
18+
19+ Widget networkButton (String label, String url) {
20+ final bool isActive = selectedNetwork == url && errorMessage == null ;
21+ final colorScheme = Theme .of (context).colorScheme;
22+
23+ return SizedBox (
24+ width: MediaQuery .of (context).size.width / 3 ,
25+ child: ElevatedButton (
26+ style: ElevatedButton .styleFrom (
27+ backgroundColor:
28+ isActive ? colorScheme.primaryContainer : colorScheme.surface,
29+ shape: RoundedRectangleBorder (
30+ borderRadius: BorderRadius .circular (6 ),
31+ side: BorderSide (
32+ color:
33+ isActive ? colorScheme.primaryContainer : colorScheme.outline,
34+ ),
35+ ),
36+ ),
37+ onPressed: () => _onNetworkSelected (url),
38+ child: Text (
39+ label,
40+ style: TextStyle (
41+ color: isActive
42+ ? colorScheme.onPrimaryContainer
43+ : colorScheme.onSurfaceVariant,
44+ ),
45+ ),
46+ ),
47+ );
48+ }
49+
50+ void _onNetworkSelected (String url) {
51+ setState (() {
52+ selectedNetwork = url;
53+ urlController.text = url;
54+ errorMessage = null ;
55+ });
56+ }
1757
1858 @override
1959 Widget build (BuildContext context) {
20- const size = 100.0 ;
2160 final content = Padding (
2261 padding: const EdgeInsets .all (16.0 ),
2362 child: KeyboardVisibilityBuilder (builder: (context, isKeyboardVisible) {
@@ -36,6 +75,7 @@ class _CouncilScreenState extends State<CouncilScreen> {
3675 controller: urlController,
3776 onChanged: (value) {
3877 final v = value.trim ();
78+ selectedNetwork = v;
3979 if (v.isEmpty) {
4080 errorMessage = 'URL is required' ;
4181 setState (() {});
@@ -60,55 +100,31 @@ class _CouncilScreenState extends State<CouncilScreen> {
60100 labelText: 'TFChain URL' ,
61101 errorText: errorMessage,
62102 )),
63- const SizedBox (height: 50 ),
64- Row (
65- mainAxisAlignment: MainAxisAlignment .spaceEvenly ,
103+ const SizedBox (height: 30 ),
104+ Column (
105+ mainAxisAlignment: MainAxisAlignment .center ,
66106 children: [
67- ElevatedButton (
68- style : ElevatedButton . styleFrom (
69- fixedSize : const Size . fromWidth (size)),
70- onPressed : () {
71- urlController.text = 'wss://tfchain.dev.grid.tf' ;
72- errorMessage = null ;
73- setState (() {});
74- } ,
75- child : const Text ( 'Devnet' ) ),
76- ElevatedButton (
77- style : ElevatedButton . styleFrom (
78- fixedSize : const Size . fromWidth (size)),
79- onPressed : () {
80- urlController.text = ' wss://tfchain.qa .grid.tf';
81- errorMessage = null ;
82- setState (() {});
83- } ,
84- child : const Text ( 'QAnet' ) ),
107+ Row (
108+ mainAxisAlignment : MainAxisAlignment .center,
109+ children : [
110+ networkButton ( 'Devnet' , 'wss://tfchain.dev.grid.tf' ),
111+ const SizedBox (width : 30 ),
112+ networkButton ( 'QAnet' , 'wss://tfchain.qa.grid.tf' ),
113+ ],
114+ ) ,
115+ const SizedBox (height : 20 ),
116+ Row (
117+ mainAxisAlignment : MainAxisAlignment .center,
118+ children : [
119+ networkButton (
120+ 'Testnet' , ' wss://tfchain.test .grid.tf'),
121+ const SizedBox (width : 30 ),
122+ networkButton ( 'Mainnet' , 'wss://tfchain.grid.tf' ),
123+ ] ,
124+ ),
85125 ],
86126 ),
87127 const SizedBox (height: 20 ),
88- Row (
89- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
90- children: [
91- ElevatedButton (
92- style: ElevatedButton .styleFrom (
93- fixedSize: const Size .fromWidth (size)),
94- onPressed: () {
95- urlController.text = 'wss://tfchain.test.grid.tf' ;
96- errorMessage = null ;
97- setState (() {});
98- },
99- child: const Text ('Testnet' )),
100- ElevatedButton (
101- style: ElevatedButton .styleFrom (
102- fixedSize: const Size .fromWidth (size)),
103- onPressed: () {
104- urlController.text = 'wss://tfchain.grid.tf' ;
105- errorMessage = null ;
106- setState (() {});
107- },
108- child: const Text ('Mainnet' )),
109- ],
110- ),
111- const SizedBox (height: 50 ),
112128 ElevatedButton (
113129 onPressed: () {
114130 if (errorMessage == null ) {
0 commit comments