refacto: headerprofileview

This commit is contained in:
guenoel 2022-11-17 15:43:49 +01:00
parent 2bf5adf049
commit 0cfd7ba2b0
4 changed files with 125 additions and 108 deletions

View File

@ -1,20 +1,13 @@
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/models/widgets_keys.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);
@ -129,102 +122,6 @@ class WalletsProfilesProvider with ChangeNotifier {
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);
return Stack(children: <Widget>[
Consumer<SubstrateSdk>(builder: (context, sub, _) {
bool isAccountExist = balanceCache[address] != 0;
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: keyCopyAddress,
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),
]);
}
bool isContact(String address) {
return contactsBox.containsKey(address);
}

View File

@ -8,10 +8,10 @@ import 'package:gecko/models/widgets_keys.dart';
import 'package:gecko/providers/cesium_plus.dart';
import 'package:gecko/providers/duniter_indexer.dart';
import 'package:gecko/providers/substrate_sdk.dart';
import 'package:gecko/providers/wallets_profiles.dart';
import 'package:flutter/material.dart';
import 'package:gecko/screens/wallet_view.dart';
import 'package:gecko/widgets/bottom_app_bar.dart';
import 'package:gecko/widgets/header_profile_view.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import 'package:provider/provider.dart';
@ -32,8 +32,6 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
WalletsProfilesProvider walletProfile =
Provider.of<WalletsProfilesProvider>(context, listen: false);
return Scaffold(
key: _scaffoldKey,
@ -47,7 +45,8 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
),
bottomNavigationBar: BottomAppBarCustom(context: context),
body: Column(children: <Widget>[
walletProfile.headerProfileView(context, address, username),
HeaderProfileView(
context: context, address: address, username: username),
historyQuery(context),
]));
}

View File

@ -19,6 +19,7 @@ import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
import 'package:gecko/screens/qrcode_fullscreen.dart';
import 'package:gecko/screens/transaction_in_progress.dart';
import 'package:gecko/widgets/bottom_app_bar.dart';
import 'package:gecko/widgets/header_profile_view.dart';
import 'package:provider/provider.dart';
import 'package:qr_flutter/qr_flutter.dart';
@ -105,7 +106,8 @@ class WalletViewScreen extends StatelessWidget {
bottomNavigationBar: BottomAppBarCustom(context: context),
body: SafeArea(
child: Column(children: <Widget>[
walletProfile.headerProfileView(context, address, username),
HeaderProfileView(
context: context, address: address, username: username),
SizedBox(height: isTall ? 10 : 0),
Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
Column(children: <Widget>[

View File

@ -0,0 +1,119 @@
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/widgets_keys.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/providers/wallets_profiles.dart';
import 'package:gecko/screens/common_elements.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
class HeaderProfileView extends StatelessWidget {
const HeaderProfileView({
Key? key,
required this.context,
required this.address,
required this.username,
}) : super(key: key);
final BuildContext context;
final String address;
final String? username;
@override
Widget build(BuildContext context) {
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);
return Stack(children: <Widget>[
Consumer<SubstrateSdk>(builder: (context, sub, _) {
bool isAccountExist = balanceCache[address] != 0;
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: keyCopyAddress,
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),
]);
}
}