183 lines
5.5 KiB
Dart
183 lines
5.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:novyronst/common/api/api_string.dart';
|
|
import 'package:novyronst/common/api/user_request.dart';
|
|
import 'package:novyronst/common/help/app_nav.dart';
|
|
import 'package:novyronst/common/help/help_image.dart';
|
|
import 'package:novyronst/common/model/novyronst_user.dart';
|
|
import 'package:novyronst/pages/my/pages/about_page.dart';
|
|
import 'package:novyronst/pages/my/pages/mine_history_page.dart';
|
|
import 'package:novyronst/pages/my/pages/mine_link_page.dart';
|
|
import 'package:novyronst/pages/my/widgets/ny_dash_line.dart';
|
|
import 'package:novyronst/root/lib_export.dart';
|
|
import 'package:novyronst/tools/widgets/app_bg_page.dart';
|
|
import 'package:novyronst/tools/widgets/app_toast_util.dart';
|
|
import 'package:novyronst/tools/widgets/extend_widget.dart';
|
|
import 'package:novyronst/tools/widgets/novy_com_widget.dart';
|
|
|
|
class MyPage extends StatefulWidget {
|
|
const MyPage({super.key});
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _RootPageState();
|
|
}
|
|
}
|
|
|
|
class _RootPageState extends State<MyPage> {
|
|
|
|
final List<String> _titles = [
|
|
'History', 'Settings', 'About', 'Privacy Policy', 'User Agreement'
|
|
];
|
|
NovyronstUser? _userInfo;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_getUserInfo();
|
|
}
|
|
|
|
void _getUserInfo() {
|
|
UserRequest.getUserInfo().then((value) {
|
|
setState(() {
|
|
_userInfo = value;
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBgPage(
|
|
typeBg: 2,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
SizedBox(height: AppScreen.statusBarHeight + 48),
|
|
_buildUserInfo(),
|
|
const SizedBox(height: 26),
|
|
...List.generate(_titles.length, (index) {
|
|
return _buildSectionView(_titles[index], index, onTap: () {
|
|
if (index == 0) {
|
|
AppNav.to(MineHistoryPage());
|
|
} else if (index == 1) {
|
|
|
|
} else if (index == 2) {
|
|
|
|
AppNav.to(AboutUsPage());
|
|
|
|
} else if (index == 3) {
|
|
AppNav.to(MineLinkPage(urlString: ApiString.webPrivacy,
|
|
title: 'Privacy Policy',
|
|
));
|
|
} else if (index == 4) {
|
|
AppNav.to(MineLinkPage(urlString: ApiString.webAgreement,
|
|
title: 'User Agreement',
|
|
));
|
|
}
|
|
});
|
|
})
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildSectionView(String title, int index, {Function()? onTap}) {
|
|
String imgName = ConstImage.history;
|
|
if (index == 1) {
|
|
imgName = ConstImage.settings;
|
|
} else if (index == 2) {
|
|
imgName = ConstImage.about;
|
|
} else if (index == 3) {
|
|
imgName = ConstImage.primary;
|
|
} else if (index == 4) {
|
|
imgName = ConstImage.webSite;
|
|
}
|
|
return Container(
|
|
height: 60,
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: Column(
|
|
children: [
|
|
Expanded(child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
HelpImage.asset(imgName, width: 36, height: 36),
|
|
const SizedBox(width: 10),
|
|
NovyText(title,
|
|
fontSize: 14,
|
|
)
|
|
],
|
|
),
|
|
Icon(Icons.arrow_forward_ios, size: 17, color: Colors.white)
|
|
],
|
|
)),
|
|
if (index < 4) NyDashLine()
|
|
],
|
|
),
|
|
).addInkWell(onTap: onTap);
|
|
}
|
|
|
|
Widget _buildUserInfo() {
|
|
|
|
String _name = 'Visitor';
|
|
String _customerId = '';
|
|
if (_userInfo != null) {
|
|
_name = _userInfo!.givingName!.isEmpty || _userInfo!.givingName==''
|
|
? 'Visitor'
|
|
: _userInfo!.givingName!;
|
|
_customerId = _userInfo!.customerId;
|
|
}
|
|
|
|
return Row(
|
|
children: [
|
|
Container(
|
|
clipBehavior: Clip.antiAlias,
|
|
width: 60, height: 60,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(30),
|
|
border: Border.all(color: Colors.white.withAlpha(127), width: 1)
|
|
),
|
|
child: ClipOval(
|
|
child: HelpImage.asset(ConstImage.homeTopLogo, width: 60, height: 60, fit: BoxFit.fill),
|
|
)
|
|
),
|
|
const SizedBox(width: 16),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
NovyText(_name,
|
|
fontSize: 18,
|
|
),
|
|
const SizedBox(height: 6),
|
|
Container(
|
|
height: 18,
|
|
padding: const EdgeInsets.symmetric(horizontal: 9),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white.withAlpha(60),
|
|
borderRadius: BorderRadius.circular(9),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
NovyText('ID: $_customerId',
|
|
fontSize: 11,
|
|
),
|
|
const SizedBox(width: 6),
|
|
HelpImage.asset(ConstImage.copy, width: 12, height: 12)
|
|
],
|
|
),
|
|
).addInkWell(onTap: () async {
|
|
// copy
|
|
if (_userInfo!.customerId.isEmpty) return;
|
|
await Clipboard.setData(ClipboardData(text: _userInfo!.customerId));
|
|
AppToastUtil.showSuccess('ID is Copied!');
|
|
}),
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
} |