Skip to content

Commit 1a8c36d

Browse files
refactor: changed the design of drop down menu
1 parent c3be419 commit 1a8c36d

3 files changed

Lines changed: 53 additions & 125 deletions

File tree

threefold_connect/lib/features/dao page/data/vote.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import 'package:tfchain_client/generated/dev/types/pallet_dao/proposal/dao_votes
22
import 'package:tfchain_client/tfchain_client.dart';
33

44
//TODO: mnemonic need to be changed with user mnemonic
5-
const mnemonic =
6-
"print also path fish pizza cannon seminar prison piano merry endorse flight";
5+
const mnemonic = "";
76

87
Future<DaoVotes> vote(bool vote, String hash, int farmId) async {
98
try {

threefold_connect/lib/features/dao page/presentation/widgets/vote_dialog.dart

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/cupertino.dart';
12
import 'package:flutter/material.dart';
23
import 'package:gridproxy_client/models/farms.dart';
34
import 'package:tfchain_client/models/dao.dart';
@@ -22,7 +23,8 @@ class _VoteDialogState extends State<VoteDialog> {
2223
List<Farm> farms = [];
2324

2425
void setFarms() async {
25-
List<Farm> farmsList = await getMyFarms(8711); //TODO: replace with actual twin id
26+
List<Farm> farmsList =
27+
await getMyFarms(0); //TODO: replace with actual twin id
2628
setState(() {
2729
farms = farmsList;
2830
});
@@ -60,50 +62,65 @@ class _VoteDialogState extends State<VoteDialog> {
6062
direction: Axis.vertical,
6163
mainAxisSize: MainAxisSize.min,
6264
children: [
63-
Flexible(
64-
fit: FlexFit.loose,
65-
child: DropdownMenu(
66-
menuHeight: MediaQuery.sizeOf(context).width * 0.5,
67-
enableFilter: true,
68-
width: MediaQuery.sizeOf(context).width * 0.6,
69-
textStyle: TextStyle(color: white, fontFamily: interBold),
70-
inputDecorationTheme: const InputDecorationTheme(
71-
filled: true,
72-
fillColor: backgroundColor,
73-
border: OutlineInputBorder(
74-
borderRadius: BorderRadius.all(Radius.circular(15)),
75-
borderSide: BorderSide.none,
65+
DropdownMenu(
66+
menuHeight: MediaQuery.sizeOf(context).height * 0.3,
67+
enableFilter: true,
68+
width: MediaQuery.sizeOf(context).width * 0.55,
69+
textStyle:
70+
TextStyle(color: white, fontFamily: interBold, fontSize: 14),
71+
trailingIcon: const Icon(
72+
CupertinoIcons.chevron_down,
73+
color: white,
74+
size: 18,
75+
),
76+
selectedTrailingIcon: const Icon(
77+
CupertinoIcons.chevron_up,
78+
color: white,
79+
size: 18,
80+
),
81+
inputDecorationTheme: const InputDecorationTheme(
82+
filled: true,
83+
fillColor: backgroundColor,
84+
enabledBorder: UnderlineInputBorder(
85+
borderRadius: BorderRadius.all(Radius.circular(4)),
86+
borderSide: BorderSide(
87+
color: secondaryColor,
88+
width: 8.0,
7689
),
7790
),
78-
menuStyle: MenuStyle(
79-
backgroundColor:
80-
MaterialStateProperty.all<Color>(backgroundColor),
81-
surfaceTintColor:
82-
MaterialStateProperty.all<Color>(Colors.transparent),
83-
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
84-
const RoundedRectangleBorder(
85-
borderRadius: BorderRadius.all(Radius.circular(10)),
86-
),
91+
contentPadding: EdgeInsets.only(right: 5, left: 15),
92+
),
93+
menuStyle: MenuStyle(
94+
backgroundColor:
95+
MaterialStateProperty.all<Color>(backgroundColor),
96+
surfaceTintColor:
97+
MaterialStateProperty.all<Color>(Colors.transparent),
98+
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
99+
const RoundedRectangleBorder(
100+
borderRadius: BorderRadius.all(Radius.circular(4)),
87101
),
88102
),
89-
label: Text(
90-
'Select Farm',
91-
style: TextStyle(color: white, fontFamily: interBold),
92-
),
93-
dropdownMenuEntries: _buildDropdownMenuEntries(farms),
94-
onSelected: (int? value) {
95-
if (value != null) {
96-
farmId = value;
97-
}
98-
},
103+
padding: MaterialStateProperty.all<EdgeInsets>(
104+
const EdgeInsets.only(right: 5, left: 15, bottom: 5)),
105+
),
106+
label: Text(
107+
'Select Farm',
108+
style: TextStyle(
109+
color: white, fontFamily: interBold, fontSize: 14),
99110
),
111+
dropdownMenuEntries: _buildDropdownMenuEntries(farms),
112+
onSelected: (int? value) {
113+
if (value != null) {
114+
farmId = value;
115+
}
116+
},
100117
),
101118
const SizedBox(height: 20),
102119
Row(
103120
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
104121
children: [
105122
TextButton(
106-
onPressed: () async {
123+
onPressed: () {
107124
if (farmId != null) {
108125
vote(true, widget.proposal.hash, farmId!);
109126
}
@@ -124,7 +141,7 @@ class _VoteDialogState extends State<VoteDialog> {
124141
),
125142
),
126143
TextButton(
127-
onPressed: () async {
144+
onPressed: () {
128145
if (farmId != null) {
129146
vote(false, widget.proposal.hash, farmId!);
130147
}

threefold_connect/lib/main.dart

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ void main() {
99
class MyApp extends StatelessWidget {
1010
const MyApp({super.key});
1111

12-
// This widget is the root of your application.
1312
@override
1413
Widget build(BuildContext context) {
1514
return MaterialApp(
@@ -20,90 +19,3 @@ class MyApp extends StatelessWidget {
2019
}
2120
}
2221

23-
class MyHomePage extends StatefulWidget {
24-
const MyHomePage({super.key, required this.title});
25-
26-
// This widget is the home page of your application. It is stateful, meaning
27-
// that it has a State object (defined below) that contains fields that affect
28-
// how it looks.
29-
30-
// This class is the configuration for the state. It holds the values (in this
31-
// case the title) provided by the parent (in this case the App widget) and
32-
// used by the build method of the State. Fields in a Widget subclass are
33-
// always marked "final".
34-
35-
final String title;
36-
37-
@override
38-
State<MyHomePage> createState() => _MyHomePageState();
39-
}
40-
41-
class _MyHomePageState extends State<MyHomePage> {
42-
int _counter = 0;
43-
44-
void _incrementCounter() {
45-
setState(() {
46-
// This call to setState tells the Flutter framework that something has
47-
// changed in this State, which causes it to rerun the build method below
48-
// so that the display can reflect the updated values. If we changed
49-
// _counter without calling setState(), then the build method would not be
50-
// called again, and so nothing would appear to happen.
51-
_counter++;
52-
});
53-
}
54-
55-
@override
56-
Widget build(BuildContext context) {
57-
// This method is rerun every time setState is called, for instance as done
58-
// by the _incrementCounter method above.
59-
//
60-
// The Flutter framework has been optimized to make rerunning build methods
61-
// fast, so that you can just rebuild anything that needs updating rather
62-
// than having to individually change instances of widgets.
63-
return Scaffold(
64-
appBar: AppBar(
65-
// TRY THIS: Try changing the color here to a specific color (to
66-
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
67-
// change color while the other colors stay the same.
68-
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
69-
// Here we take the value from the MyHomePage object that was created by
70-
// the App.build method, and use it to set our appbar title.
71-
title: Text(widget.title),
72-
),
73-
body: Center(
74-
// Center is a layout widget. It takes a single child and positions it
75-
// in the middle of the parent.
76-
child: Column(
77-
// Column is also a layout widget. It takes a list of children and
78-
// arranges them vertically. By default, it sizes itself to fit its
79-
// children horizontally, and tries to be as tall as its parent.
80-
//
81-
// Column has various properties to control how it sizes itself and
82-
// how it positions its children. Here we use mainAxisAlignment to
83-
// center the children vertically; the main axis here is the vertical
84-
// axis because Columns are vertical (the cross axis would be
85-
// horizontal).
86-
//
87-
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
88-
// action in the IDE, or press "p" in the console), to see the
89-
// wireframe for each widget.
90-
mainAxisAlignment: MainAxisAlignment.center,
91-
children: <Widget>[
92-
const Text(
93-
'You have pushed the button this many times:',
94-
),
95-
Text(
96-
'$_counter',
97-
style: Theme.of(context).textTheme.headlineMedium,
98-
),
99-
],
100-
),
101-
),
102-
floatingActionButton: FloatingActionButton(
103-
onPressed: _incrementCounter,
104-
tooltip: 'Increment',
105-
child: const Icon(Icons.add),
106-
), // This trailing comma makes auto-formatting nicer for build methods.
107-
);
108-
}
109-
}

0 commit comments

Comments
 (0)