Skip to content

Commit 725fc32

Browse files
committed
fix: fetch error & fit Desktop
1 parent d3ec869 commit 725fc32

File tree

3 files changed

+101
-34
lines changed

3 files changed

+101
-34
lines changed

lib/page/detail/wallet_list_page.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ class _WalletListPageState extends State<WalletListPage> {
6767
checkCallback: (bool isCheck) async {
6868
if (isCheck) {
6969
WalletModal walletModal = Provider.of<WalletModal>(context, listen: false);
70-
walletModal.deleteWallet(walletModal.walletList.getAt(index)!, index);
70+
await walletModal.deleteWallet(walletModal.walletList.getAt(index)!, index);
71+
if (walletModal.walletList.isEmpty && mounted) {
72+
Navigator.of(context).pop(true);
73+
}
7174
}
7275
},
7376
),

lib/page/wallet/wallet_page.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class _WalletPageState extends State<WalletPage> {
9090
}
9191

9292
fetchPage() async {
93+
if (!mounted) return;
9394
setState(() {
9495
loading = true;
9596
});

lib/widget/home_widget.dart

Lines changed: 96 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:xdag/common/color.dart';
33
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
44
import 'package:xdag/common/helper.dart';
5+
import 'package:xdag/widget/desktop.dart';
56

67
class Dot extends StatelessWidget {
78
final double size;
@@ -60,6 +61,7 @@ class HomeMain extends StatefulWidget {
6061

6162
class _HomeMainState extends State<HomeMain> {
6263
int index = 0;
64+
final pageController = PageController();
6365
@override
6466
Widget build(BuildContext context) {
6567
var config = [
@@ -79,39 +81,100 @@ class _HomeMainState extends State<HomeMain> {
7981
"subTitle": AppLocalizations.of(context).welcomeDesc_3,
8082
}
8183
];
82-
return Stack(
83-
fit: StackFit.expand,
84-
children: [
85-
PageView.builder(
86-
itemCount: config.length,
87-
itemBuilder: (context, index) {
88-
return HomeMainContent(
89-
image: config[index]["image"]!,
90-
title: config[index]["title"]!,
91-
subTitle: config[index]["subTitle"]!,
92-
);
93-
},
94-
onPageChanged: (index) {
95-
setState(() {
96-
this.index = index;
97-
});
98-
},
99-
),
100-
Positioned(
101-
bottom: 25,
102-
left: 0,
103-
right: 0,
104-
child: Row(
105-
mainAxisAlignment: MainAxisAlignment.center,
106-
children: [
107-
Dot(color: index == 0 ? DarkColors.mainColor : Colors.white),
108-
const SizedBox(width: 18),
109-
Dot(color: index == 1 ? DarkColors.mainColor : Colors.white),
110-
const SizedBox(width: 18),
111-
Dot(color: index == 2 ? DarkColors.mainColor : Colors.white),
112-
],
113-
)),
114-
],
84+
return LayoutBuilder(
85+
builder: (BuildContext context, BoxConstraints constraints) {
86+
double screenHeight = MediaQuery.of(context).size.height;
87+
double contentHeight = ScreenHelper.topPadding + 55 + 20 + (ScreenHelper.bottomPadding > 0 ? ScreenHelper.bottomPadding : 20) + 50 + 20 + 50;
88+
double h = (screenHeight - contentHeight) / 2;
89+
print(screenHeight);
90+
return Stack(
91+
fit: StackFit.expand,
92+
children: [
93+
PageView.builder(
94+
itemCount: config.length,
95+
controller: pageController,
96+
itemBuilder: (context, index) {
97+
return HomeMainContent(
98+
image: config[index]["image"]!,
99+
title: config[index]["title"]!,
100+
subTitle: config[index]["subTitle"]!,
101+
);
102+
},
103+
onPageChanged: (index) {
104+
setState(() {
105+
this.index = index;
106+
});
107+
},
108+
),
109+
if (Helper.isDesktop)
110+
Positioned(
111+
top: h - 25,
112+
left: 10,
113+
width: 50,
114+
height: 50,
115+
child: MyCupertinoButton(
116+
padding: const EdgeInsets.all(0),
117+
onPressed: index != 0
118+
? () {
119+
if (index > 0) {
120+
pageController.previousPage(duration: const Duration(milliseconds: 300), curve: Curves.ease);
121+
}
122+
}
123+
: null,
124+
child: SizedBox(
125+
width: 50,
126+
height: 50,
127+
child: Center(
128+
child: Icon(
129+
Icons.arrow_back_ios,
130+
color: index != 0 ? Colors.white : Colors.white54,
131+
)),
132+
),
133+
),
134+
),
135+
if (Helper.isDesktop)
136+
Positioned(
137+
top: h - 25,
138+
right: 10,
139+
width: 50,
140+
height: 50,
141+
child: MyCupertinoButton(
142+
padding: const EdgeInsets.all(0),
143+
onPressed: index != 2
144+
? () {
145+
if (index < config.length - 1) {
146+
pageController.nextPage(duration: const Duration(milliseconds: 300), curve: Curves.ease);
147+
}
148+
}
149+
: null,
150+
child: SizedBox(
151+
width: 50,
152+
height: 50,
153+
child: Center(
154+
child: Icon(
155+
Icons.arrow_forward_ios,
156+
color: index != 2 ? Colors.white : Colors.white54,
157+
)),
158+
),
159+
),
160+
),
161+
Positioned(
162+
bottom: 25,
163+
left: 0,
164+
right: 0,
165+
child: Row(
166+
mainAxisAlignment: MainAxisAlignment.center,
167+
children: [
168+
Dot(color: index == 0 ? DarkColors.mainColor : Colors.white),
169+
const SizedBox(width: 18),
170+
Dot(color: index == 1 ? DarkColors.mainColor : Colors.white),
171+
const SizedBox(width: 18),
172+
Dot(color: index == 2 ? DarkColors.mainColor : Colors.white),
173+
],
174+
)),
175+
],
176+
);
177+
},
115178
);
116179
}
117180
}

0 commit comments

Comments
 (0)