Compare commits

..

1 Commits

Author SHA1 Message Date
9986f72e11 improve shortcut buttons. (#242) 2023-07-19 21:09:24 -07:00
7 changed files with 59 additions and 52 deletions

View File

@ -39,8 +39,9 @@ abstract class Constants {
static const String featureOpenStoryInWebView = 'open_story_in_web_view';
static const String featureLogIn = 'log_in';
static const String featurePinToTop = 'pin_to_top';
static const String featureJumpUpButton = 'jump_up_button';
static const String featureJumpDownButton = 'jump_down_button';
static const String featureJumpUpButton = 'jump_up_button_with_long_press';
static const String featureJumpDownButton =
'jump_down_button_with_long_press';
static final String happyFace = <String>[
'(๑•̀ㅂ•́)و✧',

View File

@ -349,8 +349,8 @@ class CommentsCubit extends Cubit<CommentsState> {
init(useCommentCache: true);
}
/// Jump to next root level comment.
void jump(
/// Scroll to next root level comment.
void scrollToNextRoot(
ItemScrollController itemScrollController,
ItemPositionsListener itemPositionsListener,
) {
@ -387,8 +387,8 @@ class CommentsCubit extends Cubit<CommentsState> {
}
}
/// Jump to previous root level comment.
void jumpUp(
/// Scroll to previous root level comment.
void scrollToPreviousRoot(
ItemScrollController itemScrollController,
ItemPositionsListener itemPositionsListener,
) {

View File

@ -289,7 +289,9 @@ class HackiApp extends StatelessWidget {
child: MaterialApp(
title: 'Hacki',
debugShowCheckedModeBanner: false,
theme: useTrueDark ? trueDarkTheme : theme,
theme: (useTrueDark ? trueDarkTheme : theme).copyWith(
useMaterial3: false,
),
navigatorKey: navigatorKey,
navigatorObservers: <NavigatorObserver>[
locator.get<RouteObserver<ModalRoute<dynamic>>>(),

View File

@ -32,9 +32,14 @@ class CustomFloatingActionButton extends StatelessWidget {
Icons.keyboard_arrow_up,
color: Palette.white,
),
title: const Text('Jump to previous root level comment.'),
title: const Text('Shortcut'),
description: const Text(
'''Tapping on this button will take you to the previous off-screen root level comment.''',
'''Tapping on this button will take you to the previous off-screen root level comment.\n\nLong press on it to jump to the very beginning of this thread.''',
),
child: InkWell(
onLongPress: () => itemScrollController.scrollTo(
index: 0,
duration: Durations.ms400,
),
child: FloatingActionButton.small(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
@ -43,19 +48,16 @@ class CustomFloatingActionButton extends StatelessWidget {
/// default [FloatingActionButton] animation.
heroTag: UniqueKey().hashCode,
onPressed: () {
if (state.status == CommentsStatus.loading) return;
HapticFeedbackUtil.selection();
context.read<CommentsCubit>().jumpUp(
context.read<CommentsCubit>().scrollToPreviousRoot(
itemScrollController,
itemPositionsListener,
);
},
child: Icon(
Icons.keyboard_arrow_up,
color: state.status == CommentsStatus.loading
? Palette.grey
: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.primary,
),
),
),
),
@ -65,9 +67,14 @@ class CustomFloatingActionButton extends StatelessWidget {
Icons.keyboard_arrow_down,
color: Palette.white,
),
title: const Text('Jump to next root level comment.'),
title: const Text('Shortcut'),
description: const Text(
'''Tapping on this button will take you to the next off-screen root level comment.''',
'''Tapping on this button will take you to the next off-screen root level comment.\n\nLong press on it to jump to the end of this thread.''',
),
child: InkWell(
onLongPress: () => itemScrollController.scrollTo(
index: state.comments.length,
duration: Durations.ms400,
),
child: FloatingActionButton.small(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
@ -75,19 +82,16 @@ class CustomFloatingActionButton extends StatelessWidget {
/// Same as above.
heroTag: UniqueKey().hashCode,
onPressed: () {
if (state.status == CommentsStatus.loading) return;
HapticFeedbackUtil.selection();
context.read<CommentsCubit>().jump(
context.read<CommentsCubit>().scrollToNextRoot(
itemScrollController,
itemPositionsListener,
);
},
child: Icon(
Icons.keyboard_arrow_down,
color: state.status == CommentsStatus.loading
? Palette.grey
: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.primary,
),
),
),
),

View File

@ -1414,4 +1414,4 @@ packages:
version: "3.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"
flutter: ">=3.10.5"
flutter: ">=3.10.6"

View File

@ -1,11 +1,11 @@
name: hacki
description: A Hacker News reader.
version: 1.8.1+117
version: 1.8.2+118
publish_to: none
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: "3.10.5"
flutter: "3.10.6"
dependencies:
adaptive_theme: ^3.2.0