opt: mine page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-29 10:31:22 +08:00
parent 12818ae415
commit d6898bf335

View File

@@ -35,17 +35,8 @@ class _MinePageState extends State<MinePage> {
});
}
@override
Widget build(BuildContext context) {
// 宽度以最长的行为准,便于两端对齐
return IntrinsicWidth(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 8),
Row(
Widget get _header => FittedBox(
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -63,7 +54,6 @@ class _MinePageState extends State<MinePage> {
IconButton(
iconSize: 40.0,
padding: const EdgeInsets.all(8),
// constraints: const BoxConstraints(),
style: const ButtonStyle(
tapTargetSize:
MaterialTapTargetSize.shrinkWrap, // the '2023' part
@@ -122,7 +112,18 @@ class _MinePageState extends State<MinePage> {
),
),
const SizedBox(width: 10),
]),
],
),
);
@override
Widget build(BuildContext context) {
return IntrinsicWidth(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 8),
_header,
const SizedBox(height: 10),
FutureBuilder(
future: _futureBuilderFuture,
@@ -138,7 +139,8 @@ class _MinePageState extends State<MinePage> {
},
),
],
));
),
);
}
Widget userInfoBuild(_mineController, context) {
@@ -146,14 +148,17 @@ class _MinePageState extends State<MinePage> {
TextStyle style = TextStyle(
fontSize: Theme.of(context).textTheme.titleMedium!.fontSize,
color: Theme.of(context).colorScheme.primary,
fontWeight: FontWeight.bold);
return Column(mainAxisSize: MainAxisSize.min, children: [
fontWeight: FontWeight.bold,
);
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(width: 20),
GestureDetector(
onTap: () => _mineController.onLogin(),
onTap: _mineController.onLogin,
child: ClipOval(
child: Container(
width: 70,
@@ -165,7 +170,8 @@ class _MinePageState extends State<MinePage> {
src: _mineController.userInfo.value.face,
semanticsLabel: '头像',
width: 70,
height: 70)
height: 70,
)
: Image.asset(
'assets/images/noface.jpeg',
semanticLabel: "默认头像",
@@ -175,13 +181,14 @@ class _MinePageState extends State<MinePage> {
),
),
const SizedBox(width: 16),
IntrinsicWidth(
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
FittedBox(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
@@ -197,69 +204,90 @@ class _MinePageState extends State<MinePage> {
),
],
),
),
const SizedBox(height: 8),
Text.rich(TextSpan(children: [
FittedBox(
child: Text.rich(
TextSpan(
children: [
TextSpan(
text: '硬币 ',
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
color: Theme.of(context).colorScheme.outline)),
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
TextSpan(
text: (_mineController.userInfo.value.money ?? '-')
.toString(),
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary)),
color: Theme.of(context).colorScheme.primary,
),
),
TextSpan(
text: " 经验 ",
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
color: Theme.of(context).colorScheme.outline)),
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
TextSpan(
text: "${levelInfo?.currentExp ?? '-'}",
semanticsLabel: "当前${levelInfo?.currentExp ?? '-'}",
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary)),
color: Theme.of(context).colorScheme.primary,
),
),
TextSpan(
text: "/${levelInfo?.nextExp ?? '-'}",
semanticsLabel: "升级需${levelInfo?.nextExp ?? '-'}",
style: TextStyle(
fontSize:
Theme.of(context).textTheme.labelSmall!.fontSize,
color: Theme.of(context).colorScheme.outline)),
])),
// const SizedBox(height: 4),
// Text.rich(TextSpan(children: [
// ])),
// Text.rich(
// textAlign: TextAlign.right,
// TextSpan(children: [
//
// ])),
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context).colorScheme.outline,
),
),
],
),
),
),
const SizedBox(height: 4),
LinearProgressIndicator(
minHeight: 2,
value: levelInfo != null
? (levelInfo.currentExp! / levelInfo.nextExp!)
: 0,
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
backgroundColor:
Theme.of(context).colorScheme.inversePrimary,
valueColor: AlwaysStoppedAnimation<Color>(
Theme.of(context).colorScheme.primary),
),
],
)),
),
),
const SizedBox(width: 20),
],
),
const SizedBox(height: 10),
Container(
SizedBox(
width: 240,
height: 100,
child: GridView.count(
@@ -268,7 +296,7 @@ class _MinePageState extends State<MinePage> {
crossAxisCount: 3,
children: [
InkWell(
onTap: () => _mineController.pushDynamic(),
onTap: _mineController.pushDynamic,
borderRadius: StyleString.mdRadius,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -285,7 +313,8 @@ class _MinePageState extends State<MinePage> {
key: ValueKey<String>(_mineController
.userStat.value.dynamicCount
.toString()),
style: style),
style: style,
),
),
const SizedBox(height: 8),
Text(
@@ -296,7 +325,7 @@ class _MinePageState extends State<MinePage> {
),
),
InkWell(
onTap: () => _mineController.pushFollow(),
onTap: _mineController.pushFollow,
borderRadius: StyleString.mdRadius,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -313,7 +342,8 @@ class _MinePageState extends State<MinePage> {
key: ValueKey<String>(_mineController
.userStat.value.following
.toString()),
style: style),
style: style,
),
),
const SizedBox(height: 8),
Text(
@@ -324,7 +354,7 @@ class _MinePageState extends State<MinePage> {
),
),
InkWell(
onTap: () => _mineController.pushFans(),
onTap: _mineController.pushFans,
borderRadius: StyleString.mdRadius,
child: Column(
mainAxisSize: MainAxisSize.min,
@@ -339,10 +369,10 @@ class _MinePageState extends State<MinePage> {
child: Text(
(_mineController.userStat.value.follower ?? '-')
.toString(),
key: ValueKey<String>(_mineController
.userStat.value.follower
.toString()),
style: style),
key: ValueKey<String>(
_mineController.userStat.value.follower.toString()),
style: style,
),
),
const SizedBox(height: 8),
Text(
@@ -353,39 +383,9 @@ class _MinePageState extends State<MinePage> {
),
),
],
)),
]);
}
}
class ActionItem extends StatelessWidget {
final Icon? icon;
final Function? onTap;
final String? text;
const ActionItem({
super.key,
this.icon,
this.onTap,
this.text,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {},
borderRadius: StyleString.mdRadius,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon!.icon!),
const SizedBox(height: 8),
Text(
text!,
style: Theme.of(context).textTheme.labelMedium,
),
),
],
),
);
}
}