Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğecko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Ğecko
Commits
c07cc904
Commit
c07cc904
authored
2 years ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
workaround dropdown
parent
5e5e6ee4
No related branches found
No related tags found
1 merge request
!25
wip: use dropdown to chose auto or manual endpoints
Pipeline
#16507
failed
2 years ago
Stage: format
Stage: build_and_test
Stage: package
Changes
4
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/providers/substrate_sdk.dart
+30
-9
30 additions, 9 deletions
lib/providers/substrate_sdk.dart
lib/screens/settings.dart
+49
-48
49 additions, 48 deletions
lib/screens/settings.dart
pubspec.lock
+7
-0
7 additions, 0 deletions
pubspec.lock
pubspec.yaml
+1
-0
1 addition, 0 deletions
pubspec.yaml
with
87 additions
and
57 deletions
lib/providers/substrate_sdk.dart
+
30
−
9
View file @
c07cc904
...
...
@@ -46,7 +46,6 @@ class SubstrateSdk with ChangeNotifier {
}
Future
<
void
>
connectNode
(
BuildContext
ctx
)
async
{
List
<
NetworkParams
>
node
=
[];
HomeProvider
_homeProvider
=
Provider
.
of
<
HomeProvider
>(
ctx
,
listen:
false
);
// var connectivityResult = await (Connectivity().checkConnectivity());
...
...
@@ -57,13 +56,14 @@ class SubstrateSdk with ChangeNotifier {
// }
_homeProvider
.
changeMessage
(
"connectionPending"
.
tr
(),
0
);
for
(
String
_endpoint
in
configBox
.
get
(
'endpoint'
))
{
final
n
=
NetworkParams
();
n
.
name
=
currencyName
;
n
.
endpoint
=
_endpoint
;
n
.
ss58
=
ss58
;
node
.
add
(
n
);
}
// configBox.delete('customEndpoint');
final
List
<
NetworkParams
>
listEndpoints
=
configBox
.
containsKey
(
'customEndpoint'
)
?
[
getDuniterCustomEndpoint
()]
:
getDuniterBootstrap
();
// final nodes = getDuniterBootstrap();
int
timeout
=
10000
;
// if (n.endpoint!.startsWith('ws://')) {
...
...
@@ -93,7 +93,7 @@ class SubstrateSdk with ChangeNotifier {
isLoadingEndpoint
=
true
;
notifyListeners
();
final
res
=
await
sdk
.
api
.
connectNode
(
keyring
,
node
)
.
timeout
(
final
res
=
await
sdk
.
api
.
connectNode
(
keyring
,
listEndpoints
)
.
timeout
(
Duration
(
milliseconds:
timeout
),
onTimeout:
()
=
>
null
,
);
...
...
@@ -133,6 +133,27 @@ class SubstrateSdk with ChangeNotifier {
log
.
d
(
sdk
.
api
.
connectedNode
?.
endpoint
);
}
List
<
NetworkParams
>
getDuniterBootstrap
()
{
List
<
NetworkParams
>
node
=
[];
for
(
String
_endpoint
in
configBox
.
get
(
'endpoint'
))
{
final
n
=
NetworkParams
();
n
.
name
=
currencyName
;
n
.
endpoint
=
_endpoint
;
n
.
ss58
=
ss58
;
node
.
add
(
n
);
}
return
node
;
}
NetworkParams
getDuniterCustomEndpoint
()
{
final
nodeParams
=
NetworkParams
();
nodeParams
.
name
=
currencyName
;
nodeParams
.
endpoint
=
configBox
.
get
(
'customEndpoint'
);
nodeParams
.
ss58
=
ss58
;
return
nodeParams
;
}
Future
<
String
>
importAccount
(
{
String
mnemonic
=
''
,
bool
fromMnemonic
=
false
,
...
...
This diff is collapsed.
Click to expand it.
lib/screens/settings.dart
+
49
−
48
View file @
c07cc904
...
...
@@ -5,7 +5,9 @@ import 'package:gecko/providers/my_wallets.dart';
import
'package:gecko/providers/settings_provider.dart'
;
import
'package:gecko/providers/substrate_sdk.dart'
;
import
'package:gecko/globals.dart'
;
import
'package:polkawallet_sdk/api/types/networkParams.dart'
;
import
'package:provider/provider.dart'
;
import
'package:dropdown_button2/dropdown_button2.dart'
;
// ignore: must_be_immutable
class
SettingsScreen
extends
StatelessWidget
{
...
...
@@ -14,29 +16,21 @@ class SettingsScreen extends StatelessWidget {
SettingsScreen
({
Key
?
key
})
:
super
(
key:
key
);
// Initial Selected Value
String
dropdownvalue
=
'Item 1'
;
// List of items in our dropdown menu
var
items
=
[
'Item 1'
,
'Item 2'
,
'Item 3'
,
'Item 4'
,
'Item 5'
,
];
String
?
selectedDuniterEndpoint
;
@override
Widget
build
(
BuildContext
context
)
{
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
]);
SubstrateSdk
_sub
=
Provider
.
of
<
SubstrateSdk
>(
context
,
listen:
false
);
TextEditingController
_endpointController
=
TextEditingController
(
text:
_sub
.
sdk
.
api
.
connectedNode
?.
endpoint
??
configBox
.
get
(
'endpoint'
)
.
first
);
const
double
buttonHigh
=
50
;
const
double
buttonWidth
=
240
;
const
double
fontSize
=
16
;
// List of items in our dropdown menu
var
duniterBootstrapNodes
=
_sub
.
getDuniterBootstrap
();
selectedDuniterEndpoint
=
_sub
.
getConnectedEndpoint
();
return
Scaffold
(
backgroundColor:
backgroundColor
,
appBar:
AppBar
(
...
...
@@ -47,23 +41,7 @@ class SettingsScreen extends StatelessWidget {
)),
body:
Column
(
children:
<
Widget
>[
const
SizedBox
(
height:
60
),
Consumer
<
SettingsProvider
>(
builder:
(
context
,
_set
,
_
)
{
return
DropdownButton
(
value:
dropdownvalue
,
icon:
const
Icon
(
Icons
.
keyboard_arrow_down
),
items:
items
.
map
((
String
items
)
{
return
DropdownMenuItem
(
value:
items
,
child:
Text
(
items
),
);
})
.
toList
(),
onChanged:
(
String
?
newValue
)
{
log
.
d
(
'coucoucoucouc'
);
dropdownvalue
=
newValue
!
;
_set
.
reload
();
},
);
}),
Row
(
children:
[
Consumer
<
SubstrateSdk
>(
builder:
(
context
,
_sub
,
_
)
{
log
.
d
(
_sub
.
sdk
.
api
.
connectedNode
?.
endpoint
);
...
...
@@ -76,26 +54,49 @@ class SettingsScreen extends StatelessWidget {
?
Icons
.
check
:
Icons
.
close
),
const
Spacer
(),
SizedBox
(
width:
200
,
height:
50
,
child:
TextField
(
controller:
_endpointController
,
autocorrect:
false
,
),
Consumer
<
SettingsProvider
>(
builder:
(
context
,
_set
,
_
)
{
return
DropdownButtonHideUnderline
(
child:
DropdownButton
(
//TODO
value:
selectedDuniterEndpoint
??
duniterBootstrapNodes
.
first
.
endpoint
,
icon:
const
Icon
(
Icons
.
keyboard_arrow_down
),
items:
duniterBootstrapNodes
.
map
((
NetworkParams
_endpointParams
)
{
return
DropdownMenuItem
(
value:
_endpointParams
.
endpoint
,
child:
Text
(
_endpointParams
.
endpoint
!
),
);
})
.
toList
(),
onChanged:
(
String
?
_newEndpoint
)
{
log
.
d
(
_newEndpoint
!
);
selectedDuniterEndpoint
=
_newEndpoint
;
_set
.
reload
();
},
),
);
}),
const
Spacer
(
flex:
5
),
_sub
.
isLoadingEndpoint
?
CircularProgressIndicator
(
color:
orangeC
)
:
IconButton
(
:
Consumer
<
SettingsProvider
>(
builder:
(
context
,
_set
,
_
)
{
return
IconButton
(
icon:
Icon
(
Icons
.
send
,
color:
orangeC
,
color:
selectedDuniterEndpoint
!=
_sub
.
getConnectedEndpoint
()
?
orangeC
:
Colors
.
grey
[
500
],
size:
40
,
),
onPressed:
()
async
{
configBox
.
put
(
'endpoint'
,
[
_endpointController
.
text
]);
onPressed:
selectedDuniterEndpoint
!=
_sub
.
getConnectedEndpoint
()
?
()
async
{
configBox
.
put
(
'customEndpoint'
,
selectedDuniterEndpoint
);
await
_sub
.
connectNode
(
context
);
}
:
null
);
}),
const
Spacer
(
flex:
8
),
]),
...
...
This diff is collapsed.
Click to expand it.
pubspec.lock
+
7
−
0
View file @
c07cc904
...
...
@@ -309,6 +309,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
dropdown_button2:
dependency: "direct main"
description:
name: dropdown_button2
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.3"
durt:
dependency: "direct main"
description:
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
1
−
0
View file @
c07cc904
...
...
@@ -74,6 +74,7 @@ dependencies:
image_cropper
:
^2.0.3
easy_localization
:
^3.0.1
flutter_markdown
:
^0.6.10+2
dropdown_button2
:
^1.6.3
dev_dependencies
:
# flutter_launcher_icons: ^0.9.2
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment