lock send/receive height to fit

This commit is contained in:
julian 2022-10-26 16:00:54 -06:00
parent a6a7d56647
commit 2a27776acf
3 changed files with 721 additions and 613 deletions

View file

@ -209,6 +209,8 @@ class MyWallet extends StatefulWidget {
}
class _MyWalletState extends State<MyWallet> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Column(
@ -225,47 +227,44 @@ class _MyWalletState extends State<MyWallet> {
const SizedBox(
height: 16,
),
Expanded(
child: RoundedWhiteContainer(
padding: const EdgeInsets.all(0),
child: DefaultTabController(
length: 2,
child: Column(
children: [
TabBar(
indicatorColor: Theme.of(context)
.extension<StackColors>()!
.accentColorBlue,
labelStyle: STextStyles.desktopTextExtraSmall(context),
labelColor: Theme.of(context)
.extension<StackColors>()!
.accentColorBlue,
unselectedLabelColor: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
labelPadding: const EdgeInsets.symmetric(
vertical: 6,
),
splashBorderRadius: BorderRadius.vertical(
Container(
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.popupBG,
borderRadius: BorderRadius.vertical(
top: Radius.circular(
Constants.size.circularBorderRadius,
),
),
tabs: const [
Tab(text: "Send"),
Tab(text: "Receive"),
],
),
Expanded(
child: TabBarView(
child: SendReceiveTabMenu(
onChanged: (index) {
setState(() {
_selectedIndex = index;
});
},
),
),
Container(
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.popupBG,
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(
Constants.size.circularBorderRadius,
),
),
),
child: IndexedStack(
index: _selectedIndex,
children: [
Padding(
key: const Key("desktopSendViewPortKey"),
padding: const EdgeInsets.all(20),
child: DesktopSend(
walletId: widget.walletId,
),
),
Padding(
key: const Key("desktopReceiveViewPortKey"),
padding: const EdgeInsets.all(20),
child: DesktopReceive(
walletId: widget.walletId,
@ -274,6 +273,127 @@ class _MyWalletState extends State<MyWallet> {
],
),
),
const Spacer(),
],
);
}
}
class SendReceiveTabMenu extends StatefulWidget {
const SendReceiveTabMenu({
Key? key,
this.initialIndex = 0,
this.onChanged,
}) : super(key: key);
final int initialIndex;
final void Function(int)? onChanged;
@override
State<SendReceiveTabMenu> createState() => _SendReceiveTabMenuState();
}
class _SendReceiveTabMenuState extends State<SendReceiveTabMenu> {
late int _selectedIndex;
void _onChanged(int newIndex) {
if (_selectedIndex != newIndex) {
setState(() {
_selectedIndex = newIndex;
});
widget.onChanged?.call(_selectedIndex);
}
}
@override
void initState() {
_selectedIndex = widget.initialIndex;
super.initState();
}
@override
Widget build(BuildContext context) {
return Row(
children: [
Expanded(
child: GestureDetector(
onTap: () => _onChanged(0),
child: Container(
color: Colors.transparent,
child: Column(
children: [
const SizedBox(
height: 16,
),
Text(
"Send",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
color: _selectedIndex == 0
? Theme.of(context)
.extension<StackColors>()!
.accentColorBlue
: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
const SizedBox(
height: 19,
),
Container(
height: 2,
decoration: BoxDecoration(
color: _selectedIndex == 0
? Theme.of(context)
.extension<StackColors>()!
.accentColorBlue
: Theme.of(context)
.extension<StackColors>()!
.background,
),
),
],
),
),
),
),
Expanded(
child: GestureDetector(
onTap: () => _onChanged(1),
child: Container(
color: Colors.transparent,
child: Column(
children: [
const SizedBox(
height: 16,
),
Text(
"Receive",
style: STextStyles.desktopTextExtraSmall(context).copyWith(
color: _selectedIndex == 1
? Theme.of(context)
.extension<StackColors>()!
.accentColorBlue
: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
const SizedBox(
height: 19,
),
Container(
height: 2,
decoration: BoxDecoration(
color: _selectedIndex == 1
? Theme.of(context)
.extension<StackColors>()!
.accentColorBlue
: Theme.of(context)
.extension<StackColors>()!
.background,
),
),
],
),
),

View file

@ -199,15 +199,11 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
height: 32,
),
Center(
child: SizedBox(
width: 200,
height: 200,
child: QrImage(
data: "${coin.uriScheme}:$receivingAddress",
size: MediaQuery.of(context).size.width / 2,
foregroundColor: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
size: 200,
foregroundColor:
Theme.of(context).extension<StackColors>()!.accentColorDark,
),
),
const SizedBox(

View file

@ -541,8 +541,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
});
}
return SingleChildScrollView(
child: Column(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
@ -613,8 +612,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
ConnectionState.done &&
snapshot.hasData) {
if (ref
.read(
publicPrivateBalanceStateProvider
.read(publicPrivateBalanceStateProvider
.state)
.state ==
"Private") {
@ -691,9 +689,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
onTap: () async {
if (coin == Coin.firo || coin == Coin.firoTestNet) {
final firoWallet = ref.read(provider).wallet as FiroWallet;
if (ref
.read(publicPrivateBalanceStateProvider.state)
.state ==
if (ref.read(publicPrivateBalanceStateProvider.state).state ==
"Private") {
cryptoAmountController.text =
(await firoWallet.availablePrivateBalance())
@ -820,8 +816,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final amountString = Format.localizedStringAsFixed(
value: _amountToSend!,
locale:
ref.read(localeServiceChangeNotifierProvider).locale,
locale: ref.read(localeServiceChangeNotifierProvider).locale,
decimalPlaces: Constants.decimalPlaces,
);
@ -1001,8 +996,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final results =
AddressUtils.parseUri(qrResult.rawContent);
Logging.instance.log(
"qrResult parsed: $results",
Logging.instance.log("qrResult parsed: $results",
level: LogLevel.Info);
if (results.isNotEmpty &&
@ -1095,9 +1089,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
error,
textAlign: TextAlign.left,
style: STextStyles.label(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textError,
color:
Theme.of(context).extension<StackColors>()!.textError,
),
),
),
@ -1166,7 +1159,6 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
: null,
)
],
),
);
}
}