|
|
@ -6,6 +6,7 @@ import 'package:isekai_wiki/components/isekai_nav_bar.dart';
|
|
|
|
import 'package:isekai_wiki/models/user.dart';
|
|
|
|
import 'package:isekai_wiki/models/user.dart';
|
|
|
|
import 'package:isekai_wiki/pages/about.dart';
|
|
|
|
import 'package:isekai_wiki/pages/about.dart';
|
|
|
|
import 'package:isekai_wiki/styles.dart';
|
|
|
|
import 'package:isekai_wiki/styles.dart';
|
|
|
|
|
|
|
|
import 'package:isekai_wiki/utils/dialog.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../components/dummy_icon.dart';
|
|
|
|
import '../components/dummy_icon.dart';
|
|
|
|
import '../components/follow_scale.dart';
|
|
|
|
import '../components/follow_scale.dart';
|
|
|
@ -20,17 +21,28 @@ class OwnProfileController extends GetxController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> handleLoginClick() {
|
|
|
|
Future<void> handleLoginClick() {
|
|
|
|
handleStartAuth();
|
|
|
|
if (uc.authProcessing.isFalse) {
|
|
|
|
return Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
handleStartAuth();
|
|
|
|
|
|
|
|
return Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return Future.value();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> handleStartAuth() async {
|
|
|
|
Future<void> handleStartAuth() async {
|
|
|
|
await uc.startAuthFlow();
|
|
|
|
await uc.startAuthFlow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> handleLogoutClick() {
|
|
|
|
Future<void> handleLogoutClick() async {
|
|
|
|
handleLogout();
|
|
|
|
if (await confirm(
|
|
|
|
return Future.delayed(const Duration(milliseconds: 100));
|
|
|
|
Get.overlayContext!,
|
|
|
|
|
|
|
|
"你想要退出登录吗?",
|
|
|
|
|
|
|
|
title: "退出登录",
|
|
|
|
|
|
|
|
positiveText: "确定",
|
|
|
|
|
|
|
|
isDanger: true,
|
|
|
|
|
|
|
|
)) {
|
|
|
|
|
|
|
|
handleLogout();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> handleLogout() async {
|
|
|
|
Future<void> handleLogout() async {
|
|
|
@ -41,21 +53,20 @@ class OwnProfileController extends GetxController {
|
|
|
|
class OwnProfileTab extends StatelessWidget {
|
|
|
|
class OwnProfileTab extends StatelessWidget {
|
|
|
|
const OwnProfileTab({super.key});
|
|
|
|
const OwnProfileTab({super.key});
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildUserAvatar(UserController uc, {double size = 56}) {
|
|
|
|
Widget _buildUserAvatar(UserController uc, {double size = 64}) {
|
|
|
|
return Obx(() {
|
|
|
|
return Obx(() {
|
|
|
|
var avatarUrl = uc.getAvatar(128);
|
|
|
|
var avatarUrl = uc.getAvatar(128);
|
|
|
|
|
|
|
|
|
|
|
|
if (avatarUrl != null && avatarUrl.isNotEmpty) {
|
|
|
|
if (avatarUrl != null && avatarUrl.isNotEmpty) {
|
|
|
|
return Container(
|
|
|
|
return ClipRRect(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(size / 2)),
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(size / 2)),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
width: size,
|
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
height: size,
|
|
|
|
placeholder: (_, __) =>
|
|
|
|
placeholder: (_, __) =>
|
|
|
|
const CupertinoActivityIndicator(radius: 12),
|
|
|
|
const CupertinoActivityIndicator(radius: 12),
|
|
|
|
imageUrl: avatarUrl,
|
|
|
|
imageUrl: avatarUrl,
|
|
|
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -75,58 +86,65 @@ class OwnProfileTab extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
|
|
return FollowTextScale(
|
|
|
|
return FollowTextScale(
|
|
|
|
child: Obx(
|
|
|
|
child: Obx(
|
|
|
|
() => !uc.isLoggedIn
|
|
|
|
() => CupertinoListSection.insetGrouped(
|
|
|
|
? CupertinoListSection.insetGrouped(
|
|
|
|
backgroundColor: Styles.themePageBackgroundColor,
|
|
|
|
backgroundColor: Styles.themePageBackgroundColor,
|
|
|
|
dividerMargin: uc.isLoggedIn ? 14 : double.infinity,
|
|
|
|
children: <CupertinoListTile>[
|
|
|
|
children: <Widget>[
|
|
|
|
CupertinoListTile.notched(
|
|
|
|
Obx(
|
|
|
|
title:
|
|
|
|
() => uc.isLoggedIn
|
|
|
|
const Text('登录/注册', style: Styles.listTileLargeTitle),
|
|
|
|
? CupertinoListTile.notched(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
title: Text(uc.getDisplayName,
|
|
|
|
left: 6, right: 14, top: 0, bottom: 0),
|
|
|
|
style: Styles.listTileLargeTitle),
|
|
|
|
leading: const DummyIcon(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
color: CupertinoColors.systemGrey,
|
|
|
|
left: 6, right: 14, top: 0, bottom: 0),
|
|
|
|
icon: CupertinoIcons.person_fill,
|
|
|
|
leading: _buildUserAvatar(uc),
|
|
|
|
size: 60,
|
|
|
|
leadingSize: 80,
|
|
|
|
rounded: true,
|
|
|
|
leadingToTitle: 4,
|
|
|
|
|
|
|
|
trailing: const CupertinoListTileChevron(),
|
|
|
|
|
|
|
|
onTap: () {},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: CupertinoListTile.notched(
|
|
|
|
|
|
|
|
title:
|
|
|
|
|
|
|
|
const Text('登录/注册', style: Styles.listTileLargeTitle),
|
|
|
|
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
|
|
|
|
left: 6, right: 14, top: 0, bottom: 0),
|
|
|
|
|
|
|
|
leading: const DummyIcon(
|
|
|
|
|
|
|
|
color: CupertinoColors.systemGrey,
|
|
|
|
|
|
|
|
icon: CupertinoIcons.person_fill,
|
|
|
|
|
|
|
|
size: 64,
|
|
|
|
|
|
|
|
rounded: true,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
leadingSize: 80,
|
|
|
|
|
|
|
|
leadingToTitle: 4,
|
|
|
|
|
|
|
|
trailing: uc.authProcessing.value
|
|
|
|
|
|
|
|
? const Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.only(right: 5),
|
|
|
|
|
|
|
|
child: CupertinoActivityIndicator(
|
|
|
|
|
|
|
|
radius: 12,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: const CupertinoListTileChevron(),
|
|
|
|
|
|
|
|
onTap: c.handleLoginClick,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
leadingSize: 80,
|
|
|
|
),
|
|
|
|
leadingToTitle: 4,
|
|
|
|
AnimatedSize(
|
|
|
|
trailing: uc.authProcessing.value
|
|
|
|
duration: const Duration(milliseconds: 250),
|
|
|
|
? const Padding(
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
padding: EdgeInsets.only(right: 5),
|
|
|
|
child: SizedBox(
|
|
|
|
child: CupertinoActivityIndicator(
|
|
|
|
height: uc.isLoggedIn ? null : 0,
|
|
|
|
radius: 12,
|
|
|
|
child: CupertinoListTile.notched(
|
|
|
|
),
|
|
|
|
title: const Text('退出登录'),
|
|
|
|
)
|
|
|
|
leading: const DummyIcon(
|
|
|
|
: const CupertinoListTileChevron(),
|
|
|
|
color: CupertinoColors.systemRed,
|
|
|
|
onTap: c.handleLoginClick,
|
|
|
|
icon: CupertinoIcons.arrow_right_square,
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: CupertinoListSection.insetGrouped(
|
|
|
|
|
|
|
|
backgroundColor: Styles.themePageBackgroundColor,
|
|
|
|
|
|
|
|
children: <CupertinoListTile>[
|
|
|
|
|
|
|
|
CupertinoListTile.notched(
|
|
|
|
|
|
|
|
title: Text(uc.getDisplayName,
|
|
|
|
|
|
|
|
style: Styles.listTileLargeTitle),
|
|
|
|
|
|
|
|
leading: _buildUserAvatar(uc),
|
|
|
|
|
|
|
|
leadingSize: 80,
|
|
|
|
|
|
|
|
leadingToTitle: 4,
|
|
|
|
|
|
|
|
trailing: const CupertinoListTileChevron(),
|
|
|
|
|
|
|
|
onTap: () {},
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
CupertinoListTile.notched(
|
|
|
|
trailing: const CupertinoListTileChevron(),
|
|
|
|
title: const Text('退出登录'),
|
|
|
|
onTap: c.handleLogoutClick,
|
|
|
|
leading: const DummyIcon(
|
|
|
|
),
|
|
|
|
color: CupertinoColors.systemRed,
|
|
|
|
|
|
|
|
icon: CupertinoIcons.arrow_right_square,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
trailing: const CupertinoListTileChevron(),
|
|
|
|
|
|
|
|
onTap: () {},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|