200 lines
5.7 KiB
Dart
200 lines
5.7 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get_it/get_it.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../../../core/storage/user_storage.dart';
|
|
import '../../../web_view/web_view_page.dart';
|
|
|
|
|
|
|
|
class MyPage extends StatelessWidget {
|
|
const MyPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: SafeArea(
|
|
child: SingleChildScrollView(
|
|
padding: EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// 顶部用户信息
|
|
_buildUserInfo(),
|
|
|
|
SizedBox(height: 16),
|
|
|
|
// 中间横幅
|
|
_buildBanner(context),
|
|
|
|
SizedBox(height: 16),
|
|
|
|
// 功能列表
|
|
_buildFunctionList(context),
|
|
|
|
SizedBox(height: 16),
|
|
|
|
// 退出登录按钮
|
|
_buildLogoutButton(context),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildUserInfo() {
|
|
return Row(
|
|
children: [
|
|
Container(
|
|
width: 48,
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(8),
|
|
image: DecorationImage(
|
|
image: NetworkImage('https://pic4.zhimg.com/v2-c34c61a90095abb8713de9d1dca7ec7b_r.jpg'),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('宋', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
|
Text('用户id:songchunyi', style: TextStyle(fontSize: 12, color: Colors.grey)),
|
|
],
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.edit),
|
|
onPressed: () {},
|
|
),
|
|
Spacer(),
|
|
IconButton(
|
|
icon: Icon(Icons.add),
|
|
onPressed: () {},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildBanner(BuildContext context) { // 添加 context 参数
|
|
return GestureDetector(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => WebViewPage(url: 'https://www.satabot.com/'),
|
|
),
|
|
);
|
|
},
|
|
child: Container(
|
|
width: double.infinity,
|
|
height: 160,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(12),
|
|
image: DecorationImage(
|
|
image: NetworkImage('https://c.53326.com/d/file/lan20221010/fyhj0ibovbp.jpg'),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
top: 12,
|
|
right: 12,
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.black.withOpacity(0.5),
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
'了解我们',
|
|
style: TextStyle(color: Colors.white, fontSize: 14),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
left: 12,
|
|
bottom: 12,
|
|
child: Text(
|
|
'AI赋能农业',
|
|
style: TextStyle(color: Colors.white, fontSize: 16),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
|
|
Widget _buildFunctionList(BuildContext context) { // 添加 context 参数
|
|
//https://www.satabot.com/
|
|
final items = [
|
|
{'icon': Icons.play_arrow, 'title': '操作视频', 'url': 'https://www.satabot.com/Support/index.html'},
|
|
{'icon': Icons.car_rental, 'title': '租赁服务', 'url': 'https://www.satabot.com/Leasing.html'},
|
|
{'icon': Icons.help_outline, 'title': '帮助与支持', 'url': 'https://www.satabot.com/support/index.html'},
|
|
{'icon': Icons.policy, 'title': '售后政策', 'url': 'https://www.satabot.com/Aftersales-Service.html'},
|
|
];
|
|
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12),
|
|
boxShadow: [
|
|
BoxShadow(color: Colors.grey.withOpacity(0.1), blurRadius: 4),
|
|
],
|
|
),
|
|
child: ListView.builder(
|
|
shrinkWrap: true,
|
|
itemCount: items.length,
|
|
itemBuilder: (context, index) {
|
|
final item = items[index];
|
|
return ListTile(
|
|
leading: Icon(item['icon'] as IconData),
|
|
title: Text(item['title'] as String),
|
|
trailing: Icon(Icons.arrow_forward),
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => WebViewPage(url: item['url'] as String),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildLogoutButton(BuildContext context) {
|
|
return ElevatedButton(
|
|
onPressed: () async {
|
|
await GetIt.I<UserStorage>().deleteUser();
|
|
context.go('/auth/login');
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Colors.white,
|
|
foregroundColor: Colors.red,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
|
padding: EdgeInsets.symmetric(horizontal: 32, vertical: 12),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.exit_to_app, size: 16, color: Colors.red),
|
|
SizedBox(width: 8),
|
|
Text('退出登录'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|