Skip to content

Commit ccab56b

Browse files
author
ChenDoXiu
committed
update profile setting
1 parent 3b8a2a2 commit ccab56b

File tree

6 files changed

+116
-24
lines changed

6 files changed

+116
-24
lines changed

lib/pages/home/home_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,14 @@ class NavBar extends HookConsumerWidget {
292292
NavbarItem(
293293
icon: TablerIcons.settings,
294294
label: S.current.settings,
295-
id: "settingsAccountManager",
295+
id: "settingProfile",
296296
currentId: currentId ?? '',
297297
onSelect: () {
298298
if (onSelect != null) {
299299
onSelect!();
300300
}
301301

302-
context.goNamed("settingsAccountManager");
302+
context.goNamed("settingProfile");
303303
},
304304
)
305305
else

lib/pages/settings/profile/profile.dart

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
33
import 'package:hooks_riverpod/hooks_riverpod.dart';
4+
import 'package:moekey/widgets/mk_card.dart';
5+
import 'package:moekey/widgets/mk_image.dart';
46
import 'package:moekey/widgets/mk_input.dart';
57
import 'package:moekey/widgets/mk_scaffold.dart';
68

@@ -31,6 +33,7 @@ class SettingsProfile extends HookConsumerWidget {
3133
mainAxisAlignment: MainAxisAlignment.start,
3234
crossAxisAlignment: CrossAxisAlignment.start,
3335
children: [
36+
_ProfileMemberCard(),
3437
MkFormItem(
3538
label: "昵称",
3639
child: MkInput(
@@ -42,8 +45,8 @@ class SettingsProfile extends HookConsumerWidget {
4245
label: "个人简介",
4346
helperText: "你可以在个人简介中包含一些#标签。",
4447
child: MkInput(
45-
maxLines: 3,
4648
value: meDetail.description,
49+
minLines: 3,
4750
),
4851
),
4952
MkFormItem(
@@ -95,3 +98,75 @@ class MkFormItem extends HookConsumerWidget {
9598
);
9699
}
97100
}
101+
102+
class _ProfileMemberCard extends HookConsumerWidget {
103+
const _ProfileMemberCard({super.key});
104+
105+
@override
106+
Widget build(BuildContext context, WidgetRef ref) {
107+
var meDetail = ref.watch(currentMeDetailedProvider).valueOrNull;
108+
return SizedBox(
109+
height: 216,
110+
child: MkCard(
111+
padding: EdgeInsets.zero,
112+
child: SizedBox(
113+
height: 130,
114+
child: Stack(
115+
children: [
116+
Positioned(
117+
top: 0,
118+
left: 0,
119+
right: 0,
120+
child: [
121+
if (meDetail?.bannerUrl != null)
122+
MkImage(
123+
meDetail!.bannerUrl!,
124+
fit: BoxFit.cover,
125+
blurHash: meDetail.bannerBlurhash,
126+
width: double.infinity,
127+
height: 130,
128+
)
129+
else
130+
Container(
131+
color: const Color.fromARGB(40, 0, 0, 0),
132+
height: 130,
133+
),
134+
][0],
135+
),
136+
Positioned(
137+
right: 10,
138+
top: 10,
139+
child: FilledButton(
140+
onPressed: () {},
141+
child: const Text(
142+
"修改横幅",
143+
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
144+
),
145+
),
146+
),
147+
Positioned(
148+
bottom: 16,
149+
left: 0,
150+
right: 0,
151+
child: Column(
152+
mainAxisAlignment: MainAxisAlignment.center,
153+
spacing: 16,
154+
children: [
155+
MkImage(
156+
meDetail?.avatarUrl ?? "",
157+
width: 72,
158+
height: 72,
159+
shape: BoxShape.circle,
160+
fit: BoxFit.cover,
161+
),
162+
FilledButton(onPressed: () {}, child: Text("修改头像")),
163+
],
164+
),
165+
)
166+
],
167+
),
168+
),
169+
),
170+
);
171+
}
172+
}

lib/pages/users/user_follow.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ class UserFollow extends _$UserFollow {
111111
return MkLoadMoreListModel();
112112
}
113113

114-
Future<List<UserFullModel>> follow({String? untilId, String? sinceId}) async {
114+
String? untilId;
115+
116+
Future<List<UserFullModel>> follow() async {
115117
var api = ref.read(misskeyApisProvider);
116118
var list = await api.user
117-
.follow(userId: userId, type: type, untilId: untilId, sinceId: sinceId);
119+
.follow(userId: userId, type: type, untilId: untilId, limit: 20);
118120
if (list.isEmpty) return [];
121+
untilId = list.last.id;
119122
return List<UserFullModel>.from(list.map(
120123
(e) => e.followee ?? e.follower!,
121124
));
@@ -128,17 +131,12 @@ class UserFollow extends _$UserFollow {
128131
if (!(state.value?.hasMore ?? true)) return;
129132
loading = true;
130133
try {
131-
String? untilId;
132-
if (state.valueOrNull?.list.isNotEmpty ?? false) {
133-
untilId = state.valueOrNull?.list.last.id;
134-
}
135134
List<UserFullModel> notesList;
136-
137-
notesList = await follow(untilId: untilId);
135+
notesList = await follow();
138136

139137
var model = MkLoadMoreListModel<UserFullModel>();
140138
model.list = (state.valueOrNull?.list ?? []) + notesList;
141-
if (notesList.isEmpty) {
139+
if (notesList.isEmpty || notesList.length < 20) {
142140
model.hasMore = false;
143141
}
144142
state = AsyncData(model);

lib/pages/users/user_overview.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
44
import 'package:go_router/go_router.dart';
55
import 'package:hooks_riverpod/hooks_riverpod.dart';
66
import 'package:moekey/apis/models/login_user.dart';
7+
import 'package:moekey/apis/models/note.dart';
8+
import 'package:moekey/apis/models/notification.dart';
79
import 'package:moekey/apis/models/user_full.dart';
810
import 'package:moekey/status/server.dart';
911
import 'package:moekey/status/themes.dart';
@@ -202,8 +204,8 @@ class _UserFollowsCount extends StatelessWidget {
202204
],
203205
),
204206
if (userData.followingVisibility == null ||
205-
userData.followingVisibility == "public" ||
206-
(userData.followingVisibility == "followers" &&
207+
userData.followingVisibility == FollowVisibility.PUBLIC ||
208+
(userData.followingVisibility == FollowVisibility.FOLLOWERS &&
207209
userData.isFollowing))
208210
GestureDetector(
209211
behavior: HitTestBehavior.opaque,
@@ -232,8 +234,8 @@ class _UserFollowsCount extends StatelessWidget {
232234
),
233235
),
234236
if (userData.followersVisibility == null ||
235-
userData.followersVisibility == "public" ||
236-
(userData.followersVisibility == "followers" &&
237+
userData.followersVisibility == FollowVisibility.PUBLIC ||
238+
(userData.followersVisibility == FollowVisibility.FOLLOWERS &&
237239
userData.isFollowing))
238240
GestureDetector(
239241
onTap: () {

lib/widgets/mk_input.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class MkInput extends ConsumerStatefulWidget {
3232
this.onChanged,
3333
this.value,
3434
this.maxLines,
35+
this.keyboardType,
36+
this.maxLength,
37+
this.minLines,
3538
});
3639

3740
final String? label;
@@ -40,6 +43,9 @@ class MkInput extends ConsumerStatefulWidget {
4043
final void Function(String)? onChanged;
4144
final String? value;
4245
final int? maxLines;
46+
final TextInputType? keyboardType;
47+
final int? maxLength;
48+
final int? minLines;
4349

4450
@override
4551
ConsumerState<MkInput> createState() => _MkInputState();
@@ -102,7 +108,10 @@ class _MkInputState extends ConsumerState<MkInput> {
102108
cursorWidth: 1,
103109
style: const TextStyle(fontSize: 14),
104110
cursorColor: themes.fgColor,
105-
maxLines: widget.maxLines ?? 1,
111+
maxLines: widget.maxLines,
112+
minLines: widget.minLines,
113+
keyboardType: widget.keyboardType,
114+
maxLength: widget.maxLength,
106115
textAlignVertical: TextAlignVertical.center,
107116
)
108117
],

lib/widgets/sliver_load_more.dart

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class _SliverLoadMoreState extends State<SliverLoadMore> {
4242
// 当加载完成之后回退状态
4343
currentState = _LoadMoreStatus.done;
4444
// isTriggered = false;
45+
// 判断加载动画是否还在显示,如果还在显示,就继续加载
46+
if (context.mounted) {
47+
// 获取当前的滚动控制器
48+
}
4549
});
4650
break;
4751
case _LoadMoreStatus.loading:
@@ -60,26 +64,30 @@ class _SliverLoadMoreState extends State<SliverLoadMore> {
6064
return SliverLayoutBuilder(
6165
builder: (context, constraints) {
6266
// 没有更多了
63-
6467
if (!(widget.hasMore ?? true)) {
6568
return const SliverToBoxAdapter(
6669
child: SizedBox(
6770
height: 10,
6871
),
6972
);
7073
}
74+
7175
// 更新状态
7276
Future(() {
7377
handleNextState(constraints.remainingPaintExtent);
7478
});
7579

7680
// 显示当前状态
77-
return const SliverToBoxAdapter(
78-
child: Padding(
79-
padding: EdgeInsets.all(16.0),
80-
child: Center(
81-
child: LoadingCircularProgress(),
82-
),
81+
return SliverToBoxAdapter(
82+
child: LayoutBuilder(
83+
builder: (context, constraints) {
84+
return Padding(
85+
padding: EdgeInsets.all(16.0),
86+
child: Center(
87+
child: LoadingCircularProgress(),
88+
),
89+
);
90+
},
8391
),
8492
);
8593
},

0 commit comments

Comments
 (0)