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> { class _MyWalletState extends State<MyWallet> {
int _selectedIndex = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
@ -225,53 +227,171 @@ class _MyWalletState extends State<MyWallet> {
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
Container(
decoration: BoxDecoration(
color: Theme.of(context).extension<StackColors>()!.popupBG,
borderRadius: BorderRadius.vertical(
top: Radius.circular(
Constants.size.circularBorderRadius,
),
),
),
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,
),
),
],
),
),
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( Expanded(
child: RoundedWhiteContainer( child: GestureDetector(
padding: const EdgeInsets.all(0), onTap: () => _onChanged(0),
child: DefaultTabController( child: Container(
length: 2, color: Colors.transparent,
child: Column( child: Column(
children: [ children: [
TabBar( const SizedBox(
indicatorColor: Theme.of(context) height: 16,
.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(
top: Radius.circular(
Constants.size.circularBorderRadius,
),
),
tabs: const [
Tab(text: "Send"),
Tab(text: "Receive"),
],
), ),
Expanded( Text(
child: TabBarView( "Send",
children: [ style: STextStyles.desktopTextExtraSmall(context).copyWith(
Padding( color: _selectedIndex == 0
padding: const EdgeInsets.all(20), ? Theme.of(context)
child: DesktopSend( .extension<StackColors>()!
walletId: widget.walletId, .accentColorBlue
), : Theme.of(context)
), .extension<StackColors>()!
Padding( .textSubtitle1,
padding: const EdgeInsets.all(20), ),
child: DesktopReceive( ),
walletId: widget.walletId, 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, height: 32,
), ),
Center( Center(
child: SizedBox( child: QrImage(
width: 200, data: "${coin.uriScheme}:$receivingAddress",
height: 200, size: 200,
child: QrImage( foregroundColor:
data: "${coin.uriScheme}:$receivingAddress", Theme.of(context).extension<StackColors>()!.accentColorDark,
size: MediaQuery.of(context).size.width / 2,
foregroundColor: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
), ),
), ),
const SizedBox( const SizedBox(