Skip to content

Commit

Permalink
update profile setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenDoXiu committed Feb 4, 2025
1 parent 3b8a2a2 commit ccab56b
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 24 deletions.
4 changes: 2 additions & 2 deletions lib/pages/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ class NavBar extends HookConsumerWidget {
NavbarItem(
icon: TablerIcons.settings,
label: S.current.settings,
id: "settingsAccountManager",
id: "settingProfile",
currentId: currentId ?? '',
onSelect: () {
if (onSelect != null) {
onSelect!();
}

context.goNamed("settingsAccountManager");
context.goNamed("settingProfile");
},
)
else
Expand Down
77 changes: 76 additions & 1 deletion lib/pages/settings/profile/profile.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:moekey/widgets/mk_card.dart';
import 'package:moekey/widgets/mk_image.dart';
import 'package:moekey/widgets/mk_input.dart';
import 'package:moekey/widgets/mk_scaffold.dart';

Expand Down Expand Up @@ -31,6 +33,7 @@ class SettingsProfile extends HookConsumerWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_ProfileMemberCard(),
MkFormItem(
label: "昵称",
child: MkInput(
Expand All @@ -42,8 +45,8 @@ class SettingsProfile extends HookConsumerWidget {
label: "个人简介",
helperText: "你可以在个人简介中包含一些#标签。",
child: MkInput(
maxLines: 3,
value: meDetail.description,
minLines: 3,
),
),
MkFormItem(
Expand Down Expand Up @@ -95,3 +98,75 @@ class MkFormItem extends HookConsumerWidget {
);
}
}

class _ProfileMemberCard extends HookConsumerWidget {
const _ProfileMemberCard({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
var meDetail = ref.watch(currentMeDetailedProvider).valueOrNull;
return SizedBox(
height: 216,
child: MkCard(
padding: EdgeInsets.zero,
child: SizedBox(
height: 130,
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: [
if (meDetail?.bannerUrl != null)
MkImage(
meDetail!.bannerUrl!,
fit: BoxFit.cover,
blurHash: meDetail.bannerBlurhash,
width: double.infinity,
height: 130,
)
else
Container(
color: const Color.fromARGB(40, 0, 0, 0),
height: 130,
),
][0],
),
Positioned(
right: 10,
top: 10,
child: FilledButton(
onPressed: () {},
child: const Text(
"修改横幅",
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
),
),
),
Positioned(
bottom: 16,
left: 0,
right: 0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 16,
children: [
MkImage(
meDetail?.avatarUrl ?? "",
width: 72,
height: 72,
shape: BoxShape.circle,
fit: BoxFit.cover,
),
FilledButton(onPressed: () {}, child: Text("修改头像")),
],
),
)
],
),
),
),
);
}
}
16 changes: 7 additions & 9 deletions lib/pages/users/user_follow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ class UserFollow extends _$UserFollow {
return MkLoadMoreListModel();
}

Future<List<UserFullModel>> follow({String? untilId, String? sinceId}) async {
String? untilId;

Future<List<UserFullModel>> follow() async {
var api = ref.read(misskeyApisProvider);
var list = await api.user
.follow(userId: userId, type: type, untilId: untilId, sinceId: sinceId);
.follow(userId: userId, type: type, untilId: untilId, limit: 20);
if (list.isEmpty) return [];
untilId = list.last.id;
return List<UserFullModel>.from(list.map(
(e) => e.followee ?? e.follower!,
));
Expand All @@ -128,17 +131,12 @@ class UserFollow extends _$UserFollow {
if (!(state.value?.hasMore ?? true)) return;
loading = true;
try {
String? untilId;
if (state.valueOrNull?.list.isNotEmpty ?? false) {
untilId = state.valueOrNull?.list.last.id;
}
List<UserFullModel> notesList;

notesList = await follow(untilId: untilId);
notesList = await follow();

var model = MkLoadMoreListModel<UserFullModel>();
model.list = (state.valueOrNull?.list ?? []) + notesList;
if (notesList.isEmpty) {
if (notesList.isEmpty || notesList.length < 20) {
model.hasMore = false;
}
state = AsyncData(model);
Expand Down
10 changes: 6 additions & 4 deletions lib/pages/users/user_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:moekey/apis/models/login_user.dart';
import 'package:moekey/apis/models/note.dart';
import 'package:moekey/apis/models/notification.dart';
import 'package:moekey/apis/models/user_full.dart';
import 'package:moekey/status/server.dart';
import 'package:moekey/status/themes.dart';
Expand Down Expand Up @@ -202,8 +204,8 @@ class _UserFollowsCount extends StatelessWidget {
],
),
if (userData.followingVisibility == null ||
userData.followingVisibility == "public" ||
(userData.followingVisibility == "followers" &&
userData.followingVisibility == FollowVisibility.PUBLIC ||
(userData.followingVisibility == FollowVisibility.FOLLOWERS &&
userData.isFollowing))
GestureDetector(
behavior: HitTestBehavior.opaque,
Expand Down Expand Up @@ -232,8 +234,8 @@ class _UserFollowsCount extends StatelessWidget {
),
),
if (userData.followersVisibility == null ||
userData.followersVisibility == "public" ||
(userData.followersVisibility == "followers" &&
userData.followersVisibility == FollowVisibility.PUBLIC ||
(userData.followersVisibility == FollowVisibility.FOLLOWERS &&
userData.isFollowing))
GestureDetector(
onTap: () {
Expand Down
11 changes: 10 additions & 1 deletion lib/widgets/mk_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class MkInput extends ConsumerStatefulWidget {
this.onChanged,
this.value,
this.maxLines,
this.keyboardType,
this.maxLength,
this.minLines,
});

final String? label;
Expand All @@ -40,6 +43,9 @@ class MkInput extends ConsumerStatefulWidget {
final void Function(String)? onChanged;
final String? value;
final int? maxLines;
final TextInputType? keyboardType;
final int? maxLength;
final int? minLines;

@override
ConsumerState<MkInput> createState() => _MkInputState();
Expand Down Expand Up @@ -102,7 +108,10 @@ class _MkInputState extends ConsumerState<MkInput> {
cursorWidth: 1,
style: const TextStyle(fontSize: 14),
cursorColor: themes.fgColor,
maxLines: widget.maxLines ?? 1,
maxLines: widget.maxLines,
minLines: widget.minLines,
keyboardType: widget.keyboardType,
maxLength: widget.maxLength,
textAlignVertical: TextAlignVertical.center,
)
],
Expand Down
22 changes: 15 additions & 7 deletions lib/widgets/sliver_load_more.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class _SliverLoadMoreState extends State<SliverLoadMore> {
// 当加载完成之后回退状态
currentState = _LoadMoreStatus.done;
// isTriggered = false;
// 判断加载动画是否还在显示,如果还在显示,就继续加载
if (context.mounted) {
// 获取当前的滚动控制器
}
});
break;
case _LoadMoreStatus.loading:
Expand All @@ -60,26 +64,30 @@ class _SliverLoadMoreState extends State<SliverLoadMore> {
return SliverLayoutBuilder(
builder: (context, constraints) {
// 没有更多了

if (!(widget.hasMore ?? true)) {
return const SliverToBoxAdapter(
child: SizedBox(
height: 10,
),
);
}

// 更新状态
Future(() {
handleNextState(constraints.remainingPaintExtent);
});

// 显示当前状态
return const SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.all(16.0),
child: Center(
child: LoadingCircularProgress(),
),
return SliverToBoxAdapter(
child: LayoutBuilder(
builder: (context, constraints) {
return Padding(
padding: EdgeInsets.all(16.0),
child: Center(
child: LoadingCircularProgress(),
),
);
},
),
);
},
Expand Down

0 comments on commit ccab56b

Please sign in to comment.