Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clients
Ğecko
Commits
b03a2803
Commit
b03a2803
authored
Jun 16, 2022
by
poka
Browse files
improve headerProfileView: move to provider
parent
a4f5b44a
Pipeline
#16173
waiting for manual action with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/providers/wallets_profiles.dart
View file @
b03a2803
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:gecko/globals.dart'
;
import
'package:gecko/providers/cesium_plus.dart'
;
import
'package:gecko/providers/substrate_sdk.dart'
;
import
'package:gecko/providers/wallet_options.dart'
;
import
'package:gecko/screens/common_elements.dart'
;
import
'package:gecko/screens/wallet_view.dart'
;
import
'package:jdenticon_dart/jdenticon_dart.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
// import 'package:qrscan/qrscan.dart' as scanner;
import
'package:barcode_scan2/barcode_scan2.dart'
;
import
'package:provider/provider.dart'
;
class
WalletsProfilesProvider
with
ChangeNotifier
{
WalletsProfilesProvider
(
this
.
address
);
...
...
@@ -18,7 +24,7 @@ class WalletsProfilesProvider with ChangeNotifier {
String
?
rawSvg
;
TextEditingController
payAmount
=
TextEditingController
();
TextEditingController
payComment
=
TextEditingController
();
num
?
balance
;
num
?
_
balance
;
Future
<
String
>
scan
(
context
)
async
{
if
(
Platform
.
isAndroid
||
Platform
.
isIOS
)
{
...
...
@@ -113,13 +119,116 @@ class WalletsProfilesProvider with ChangeNotifier {
// }
Future
<
num
?>
getBalance
(
String
?
_pubkey
)
async
{
while
(
balance
==
null
)
{
while
(
_
balance
==
null
)
{
await
Future
.
delayed
(
const
Duration
(
milliseconds:
50
));
}
return
balance
;
return
_
balance
;
}
Widget
headerProfileView
(
BuildContext
context
,
String
_address
,
String
?
username
)
{
const
double
_avatarSize
=
140
;
WalletOptionsProvider
_walletOptions
=
Provider
.
of
<
WalletOptionsProvider
>(
context
,
listen:
false
);
CesiumPlusProvider
_cesiumPlusProvider
=
Provider
.
of
<
CesiumPlusProvider
>(
context
,
listen:
false
);
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
bool
isAccountExist
=
balanceCache
[
_address
]
!=
0
;
return
Stack
(
children:
<
Widget
>[
Consumer
<
SubstrateSdk
>(
builder:
(
context
,
_sub
,
_
)
{
return
Container
(
height:
180
,
decoration:
BoxDecoration
(
gradient:
LinearGradient
(
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
colors:
[
isAccountExist
?
yellowC
:
Colors
.
grey
[
400
]!,
isAccountExist
?
const
Color
(
0xFFE7811A
)
:
Colors
.
grey
[
600
]!,
],
),
));
}),
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
30
,
right:
40
),
child:
Row
(
children:
<
Widget
>[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Container
(
height:
10
,
color:
yellowC
,
// Colors.grey[400],
),
Row
(
children:
[
GestureDetector
(
key:
const
Key
(
'copyPubkey'
),
onTap:
()
{
Clipboard
.
setData
(
ClipboardData
(
text:
_address
));
snackCopyKey
(
context
);
},
child:
Text
(
getShortPubkey
(
_address
),
style:
const
TextStyle
(
fontSize:
30
,
fontWeight:
FontWeight
.
w800
,
),
),
),
]),
const
SizedBox
(
height:
25
),
balance
(
context
,
_address
,
22
),
const
SizedBox
(
height:
10
),
_walletOptions
.
idtyStatus
(
context
,
_address
,
isOwner:
false
,
color:
Colors
.
black
),
getCerts
(
context
,
_address
,
14
),
if
(
username
==
null
&&
g1WalletsBox
.
get
(
_address
)?.
username
!=
null
)
SizedBox
(
width:
230
,
child:
Text
(
g1WalletsBox
.
get
(
_address
)?.
username
??
''
,
style:
const
TextStyle
(
fontSize:
27
,
color:
Color
(
0xff814C00
),
),
),
),
if
(
username
!=
null
)
SizedBox
(
width:
230
,
child:
Text
(
username
,
style:
const
TextStyle
(
fontSize:
27
,
color:
Color
(
0xff814C00
),
),
),
),
const
SizedBox
(
height:
55
),
]),
const
Spacer
(),
Column
(
children:
<
Widget
>[
ClipOval
(
child:
_cesiumPlusProvider
.
defaultAvatar
(
_avatarSize
),
),
const
SizedBox
(
height:
25
),
]),
]),
),
CommonElements
().
offlineInfo
(
context
),
]);
}
void
reload
()
{
notifyListeners
();
}
...
...
lib/screens/activity.dart
View file @
b03a2803
...
...
@@ -3,8 +3,8 @@ import 'package:gecko/globals.dart';
import
'package:gecko/models/queries_indexer.dart'
;
import
'package:gecko/providers/cesium_plus.dart'
;
import
'package:gecko/providers/duniter_indexer.dart'
;
import
'package:gecko/providers/home.dart'
;
import
'package:gecko/providers/substrate_sdk.dart'
;
import
'package:gecko/providers/wallet_options.dart'
;
import
'package:gecko/providers/wallets_profiles.dart'
;
import
'package:flutter/material.dart'
;
import
'package:gecko/screens/wallet_view.dart'
;
...
...
@@ -30,6 +30,10 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
@override
Widget
build
(
BuildContext
context
)
{
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
]);
WalletsProfilesProvider
_walletProfile
=
Provider
.
of
<
WalletsProfilesProvider
>(
context
,
listen:
false
);
HomeProvider
_homeProvider
=
Provider
.
of
<
HomeProvider
>(
context
,
listen:
false
);
return
Scaffold
(
key:
_scaffoldKey
,
...
...
@@ -41,8 +45,9 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
child:
Text
(
'Activité du compte'
),
),
),
bottomNavigationBar:
_homeProvider
.
bottomAppBar
(
context
),
body:
Column
(
children:
<
Widget
>[
headerProfileView
(
context
),
_walletProfile
.
headerProfileView
(
context
,
address
!,
username
),
historyQuery
(
context
),
]));
}
...
...
@@ -342,86 +347,4 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
]);
}).
toList
());
}
Widget
headerProfileView
(
BuildContext
context
)
{
DuniterIndexer
_duniterIndexer
=
Provider
.
of
<
DuniterIndexer
>(
context
,
listen:
false
);
return
Column
(
children:
<
Widget
>[
Container
(
height:
10
,
color:
yellowC
,
),
Container
(
decoration:
BoxDecoration
(
gradient:
LinearGradient
(
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
colors:
[
yellowC
,
const
Color
(
0xFFE7811A
),
],
)),
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
30
,
right:
40
),
child:
Row
(
children:
<
Widget
>[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Row
(
children:
[
GestureDetector
(
key:
const
Key
(
'copyPubkey'
),
onTap:
()
{
Clipboard
.
setData
(
ClipboardData
(
text:
address
));
snackCopyKey
(
context
);
},
child:
Text
(
getShortPubkey
(
address
!),
style:
const
TextStyle
(
fontSize:
30
,
fontWeight:
FontWeight
.
w800
,
),
),
),
]),
const
SizedBox
(
height:
10
),
if
(
username
==
null
)
_duniterIndexer
.
getNameByAddress
(
context
,
address
!,
null
,
27
,
false
,
Colors
.
black
,
FontWeight
.
w400
,
FontStyle
.
normal
),
if
(
username
!=
null
)
SizedBox
(
width:
230
,
child:
Text
(
username
!,
style:
const
TextStyle
(
fontSize:
27
,
color:
Color
(
0xff814C00
),
),
),
),
const
SizedBox
(
height:
25
),
]),
balance
(
context
,
address
!,
21
),
const
SizedBox
(
height:
30
),
]),
const
Spacer
(),
Column
(
children:
<
Widget
>[
Image
.
asset
((
'assets/icon_user.png'
),
height:
50
),
const
SizedBox
(
height:
25
),
]),
]),
),
),
]);
}
}
lib/screens/wallet_view.dart
View file @
b03a2803
...
...
@@ -9,7 +9,6 @@ import 'package:gecko/providers/my_wallets.dart';
import
'package:gecko/models/wallet_data.dart'
;
import
'package:gecko/providers/wallets_profiles.dart'
;
import
'package:gecko/screens/activity.dart'
;
import
'package:gecko/screens/avatar_fullscreen.dart'
;
import
'package:gecko/screens/common_elements.dart'
;
import
'package:gecko/screens/myWallets/choose_wallet.dart'
;
import
'package:gecko/screens/myWallets/unlocking_wallet.dart'
;
...
...
@@ -31,11 +30,11 @@ class WalletViewScreen extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
portraitUp
]);
WalletsProfilesProvider
_wallet
ViewProvider
=
WalletsProfilesProvider
_wallet
Profile
=
Provider
.
of
<
WalletsProfilesProvider
>(
context
,
listen:
false
);
CesiumPlusProvider
_cesiumPlusProvider
=
Provider
.
of
<
CesiumPlusProvider
>(
context
,
listen:
false
);
_wallet
ViewProvider
.
address
=
pubkey
!;
_wallet
Profile
.
address
=
pubkey
!;
SubstrateSdk
_sub
=
Provider
.
of
<
SubstrateSdk
>(
context
,
listen:
false
);
HomeProvider
_homeProvider
=
Provider
.
of
<
HomeProvider
>(
context
,
listen:
false
);
...
...
@@ -58,13 +57,13 @@ class WalletViewScreen extends StatelessWidget {
context
,
MaterialPageRoute
(
builder:
(
context
)
{
return
QrCodeFullscreen
(
_wallet
ViewProvider
.
address
!,
_wallet
Profile
.
address
!,
);
}),
);
},
child:
QrImageWidget
(
data:
_wallet
ViewProvider
.
address
!,
data:
_wallet
Profile
.
address
!,
version:
QrVersions
.
auto
,
size:
80
,
),
...
...
@@ -76,12 +75,9 @@ class WalletViewScreen extends StatelessWidget {
),
),
bottomNavigationBar:
_homeProvider
.
bottomAppBar
(
context
),
// floatingActionButton: _homeProvider.floatingAction(context, 1),
// floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
body:
SafeArea
(
child:
Column
(
children:
<
Widget
>[
headerProfileView
(
context
,
_walletViewProvider
,
_cesiumPlusProvider
),
_walletProfile
.
headerProfileView
(
context
,
pubkey
!,
username
),
SizedBox
(
height:
isTall
?
10
:
0
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
children:
[
Column
(
children:
<
Widget
>[
...
...
@@ -382,7 +378,7 @@ class WalletViewScreen extends StatelessWidget {
)),
onTap:
_sub
.
nodeConnected
?
()
{
paymentPopup
(
context
,
_wallet
ViewProvider
);
paymentPopup
(
context
,
_wallet
Profile
);
}
:
null
),
),
...
...
@@ -695,217 +691,4 @@ class WalletViewScreen extends StatelessWidget {
});
}).
then
((
value
)
=>
_walletViewProvider
.
payAmount
.
text
=
''
);
}
Widget
headerProfileView
(
BuildContext
context
,
WalletsProfilesProvider
_historyProvider
,
CesiumPlusProvider
_cesiumPlusProvider
)
{
const
double
_avatarSize
=
140
;
WalletOptionsProvider
_walletOptions
=
Provider
.
of
<
WalletOptionsProvider
>(
context
,
listen:
false
);
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
bool
isAccountExist
=
balanceCache
[
pubkey
]
!=
0
;
return
Stack
(
children:
<
Widget
>[
Consumer
<
SubstrateSdk
>(
builder:
(
context
,
_sub
,
_
)
{
return
Container
(
height:
180
,
decoration:
BoxDecoration
(
gradient:
LinearGradient
(
begin:
Alignment
.
topCenter
,
end:
Alignment
.
bottomCenter
,
colors:
[
isAccountExist
?
yellowC
:
Colors
.
grey
[
400
]!,
isAccountExist
?
const
Color
(
0xFFE7811A
)
:
Colors
.
grey
[
600
]!,
],
),
));
}),
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
30
,
right:
40
),
child:
Row
(
children:
<
Widget
>[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Container
(
height:
10
,
color:
yellowC
,
// Colors.grey[400],
),
Row
(
children:
[
GestureDetector
(
key:
const
Key
(
'copyPubkey'
),
onTap:
()
{
Clipboard
.
setData
(
ClipboardData
(
text:
pubkey
));
snackCopyKey
(
context
);
},
child:
Text
(
getShortPubkey
(
pubkey
!),
style:
const
TextStyle
(
fontSize:
30
,
fontWeight:
FontWeight
.
w800
,
),
),
),
]),
const
SizedBox
(
height:
25
),
balance
(
context
,
pubkey
!,
22
),
const
SizedBox
(
height:
10
),
_walletOptions
.
idtyStatus
(
context
,
pubkey
!,
isOwner:
false
,
color:
Colors
.
black
),
getCerts
(
context
,
pubkey
!,
14
),
// if (username == null &&
// g1WalletsBox.get(pubkey)?.username == null)
// Query(
// options: QueryOptions(
// document: gql(getId),
// variables: {
// 'pubkey': pubkey,
// },
// ),
// builder: (QueryResult result,
// {VoidCallback? refetch, FetchMore? fetchMore}) {
// if (result.isLoading || result.hasException) {
// return const Text('...');
// } else if (result.data!['idty'] == null ||
// result.data!['idty']['username'] == null) {
// g1WalletsBox.get(pubkey)?.username = '';
// return const Text('');
// } else {
// g1WalletsBox.get(pubkey)?.username =
// result.data!['idty']['username'] ?? '';
// return SizedBox(
// width: 230,
// child: Text(
// result.data!['idty']['username'] ?? '',
// style: const TextStyle(
// fontSize: 27,
// color: Color(0xff814C00),
// ),
// ),
// );
// }
// },
// ),
if
(
username
==
null
&&
g1WalletsBox
.
get
(
pubkey
)?.
username
!=
null
)
SizedBox
(
width:
230
,
child:
Text
(
g1WalletsBox
.
get
(
pubkey
)?.
username
??
''
,
style:
const
TextStyle
(
fontSize:
27
,
color:
Color
(
0xff814C00
),
),
),
),
if
(
username
!=
null
)
SizedBox
(
width:
230
,
child:
Text
(
username
!,
style:
const
TextStyle
(
fontSize:
27
,
color:
Color
(
0xff814C00
),
),
),
),
const
SizedBox
(
height:
25
),
//// To get Cs+ name
// FutureBuilder(
// future: _cesiumPlusProvider.getName(pubkey),
// initialData: '...',
// builder: (context, snapshot) {
// return SizedBox(
// width: 230,
// child: Text(
// snapshot.data.toString(),
// style: const TextStyle(
// fontSize: 18, color: Colors.black),
// ),
// );
// }),
const
SizedBox
(
height:
30
),
]),
const
Spacer
(),
Column
(
children:
<
Widget
>[
if
(
avatar
==
null
)
ClipOval
(
child:
_cesiumPlusProvider
.
defaultAvatar
(
_avatarSize
),
),
// FutureBuilder(
// future: _cesiumPlusProvider.getAvatar(pubkey, _avatarSize),
// builder:
// (BuildContext context, AsyncSnapshot<Image?> _avatar) {
// if (_avatar.connectionState != ConnectionState.done) {
// return Stack(children: [
// ClipOval(
// child:
// _cesiumPlusProvider.defaultAvatar(_avatarSize),
// ),
// Positioned(
// top: 15,
// right: 45,
// width: 51,
// height: 51,
// child: CircularProgressIndicator(
// strokeWidth: 5,
// color: orangeC,
// ),
// ),
// ]);
// }
// if (_avatar.hasData) {
// return GestureDetector(
// key: const Key('openAvatar'),
// onTap: () {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) {
// return AvatarFullscreen(_avatar.data);
// }),
// );
// },
// child: ClipOval(
// child: Image(
// image: _avatar.data!.image,
// height: _avatarSize,
// fit: BoxFit.cover,
// ),
// ),
// );
// }
// return ClipOval(
// child: _cesiumPlusProvider.defaultAvatar(_avatarSize),
// );
// }),
if
(
avatar
!=
null
)
GestureDetector
(
key:
const
Key
(
'openAvatar'
),
onTap:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
{
return
AvatarFullscreen
(
avatar
);
}),
);
},
child:
ClipOval
(
child:
Image
(
image:
avatar
!.
image
,
height:
_avatarSize
,
fit:
BoxFit
.
cover
,
),
),
),
const
SizedBox
(
height:
25
),
]),
]),
),
CommonElements
().
offlineInfo
(
context
),
]);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment