这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/extension/scroll_controller_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import 'package:flutter/material.dart';

extension ScrollControllerExtension on ScrollController {
Future<void> scrollToTop() async {
if (!hasClients) return;
final extentBefore = position.extentBefore;
if (extentBefore == 0.0) {
return;
}
if (extentBefore == 0.0) return;
if (extentBefore < 10000.0) {
await animateTo(
position.minScrollExtent,
Expand Down
105 changes: 65 additions & 40 deletions lib/view/page/timelines_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TimelinesPage extends HookConsumerWidget {
final showPostForm = useState(false);
useEffect(
() {
controller.addListener(() {
void callback() {
final previousIndex = tabIndex.value;
final nextIndex = controller.index;
if (previousIndex == nextIndex) {
Expand Down Expand Up @@ -110,10 +110,12 @@ class TimelinesPage extends HookConsumerWidget {
}
}
tabIndex.value = nextIndex;
});
return;
}

controller.addListener(callback);
return () => controller.removeListener(callback);
},
[],
[tabs],
);
final isLargeScreen = MediaQuery.sizeOf(context).width > 1200.0;
final scaffoldKey = useMemoized(() => GlobalKey<ScaffoldState>());
Expand Down Expand Up @@ -179,21 +181,60 @@ class TimelinesPage extends HookConsumerWidget {
],
),
)
: TabBarView(
controller: controller,
physics: enableHorizontalSwipe
? null
: const NeverScrollableScrollPhysics(),
children: List.generate(
numTabs,
(index) => TimelineWidget(
tabIndex: index,
focusPostForm: () {
showPostForm.value = true;
postFormFocusNode.requestFocus();
},
: Stack(
alignment: Alignment.bottomCenter,
children: [
TabBarView(
controller: controller,
physics: enableHorizontalSwipe
? null
: const NeverScrollableScrollPhysics(),
children: List.generate(
numTabs,
(index) => TimelineWidget(
tabIndex: index,
focusPostForm: () {
showPostForm.value = true;
postFormFocusNode.requestFocus();
},
),
),
),
),
if (tabSettings != null && showPostForm.value)
Material(
clipBehavior: Clip.hardEdge,
color: colors.panel.withOpacity(0.5),
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 16.0,
sigmaY: 16.0,
),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: colors.divider.withOpacity(0.1),
width: 2.0,
),
),
),
child: SingleChildScrollView(
child: PostForm(
account: tabSettings.account,
focusNode: postFormFocusNode,
onHide: () => showPostForm.value = false,
onExpand: (account) =>
context.push('/$account/post'),
showPostButton: true,
showKeyboard: true,
maxLines: 6,
thumbnailSize: 100.0,
),
),
),
),
),
],
),
),
drawer: TimelineDrawer(controller: controller),
Expand All @@ -206,24 +247,8 @@ class TimelinesPage extends HookConsumerWidget {
child: TimelineTabBar(controller: controller),
)
: null,
floatingActionButton: tabSettings != null && showPostForm.value
? Material(
clipBehavior: Clip.hardEdge,
color: colors.panel.withOpacity(0.5),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 16.0, sigmaY: 16.0),
child: PostForm(
account: tabSettings.account,
focusNode: postFormFocusNode,
onHide: () => showPostForm.value = false,
onExpand: (account) => context.push('/$account/post'),
showPostButton: true,
showKeyboard: true,
maxLines: 6,
),
),
)
: Row(
floatingActionButton: tabSettings == null || !showPostForm.value
? Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
if (!isLargeScreen)
Expand Down Expand Up @@ -355,10 +380,10 @@ class TimelinesPage extends HookConsumerWidget {
),
),
],
),
floatingActionButtonLocation: showPostForm.value
? FloatingActionButtonLocation.centerDocked
: FloatingActionButtonLocation.centerFloat,
)
: null,
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
),
),
],
Expand Down
10 changes: 2 additions & 8 deletions lib/view/widget/mfm_keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ class MfmKeyboard extends HookConsumerWidget {
...emojis.map(
(emoji) => TextButton(
key: ValueKey(emoji),
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(
vertical: 16.0,
horizontal: 8.0,
),
),
onPressed: () =>
controller.replace(query.length + 1, emoji),
child: EmojiWidget(account: account, emoji: emoji),
Expand Down Expand Up @@ -469,7 +463,7 @@ class MfmKeyboard extends HookConsumerWidget {
});
return;
},
[],
[account, controller],
);

return Container(
Expand All @@ -479,7 +473,7 @@ class MfmKeyboard extends HookConsumerWidget {
child: TextButtonTheme(
data: TextButtonThemeData(
style: TextButton.styleFrom(
padding: const EdgeInsets.all(16.0),
padding: const EdgeInsets.symmetric(horizontal: 16.0),
minimumSize: Size.zero,
foregroundColor: Theme.of(context).colorScheme.onPrimaryContainer,
),
Expand Down
Loading