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
23 changes: 15 additions & 8 deletions lib/models/discoverable_feature.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,38 @@ enum DiscoverableFeature {
settingsShortcutOnItemScreen(
featureId: 'settings_shortcut_on_item_screen',
title: 'Go to Settings',
description: '''You can now go to settings page directly from a thread.''',
description: '''Tap to adjust thread appearance in Settings.''',
),
login(
featureId: 'log_in',
title: 'Log in for more',
description:
'''Log in using your Hacker News account to check out stories and comments you have posted in the past, and get in-app notification when there is new reply to your comments or stories.''',
'''Log in with your Hacker News account to view your past stories and comments and receive in-app notifications when someone replies to them.''',
),
pinToTop(
featureId: 'pin_to_top',
title: 'Pin a Story',
description:
'''Pin this story to the top of your home screen so that you can come back later.''',
description: '''Pin this story to the top of your home screen.''',
),
jumpUpButton(
featureId: 'jump_up_button_with_long_press',
title: 'Shortcut',
description:
'''Tapping on this button will take you to the previous root level comment.\n\nLong press on it to jump to the very beginning of this thread.''',
description: '''
Tap this button to go to the previous root-level comment.

Long press to jump to the beginning of the thread.

Drag to move the button around.''',
),
jumpDownButton(
featureId: 'jump_down_button_with_long_press',
title: 'Shortcut',
description:
'''Tapping on this button will take you to the next root level comment.\n\nLong press on it to jump to the end of this thread.''',
description: '''
Tap this button to go to the next root-level comment.

Long press to jump to the end of the thread.

Drag to move the button around.''',
),
searchInThread(
featureId: 'search_in_thread',
Expand Down
26 changes: 15 additions & 11 deletions lib/screens/item/widgets/more_popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,21 @@ class MorePopupMenu extends StatelessWidget {
isScrollControlled: true,
showDragHandle: true,
builder: (BuildContext context) {
return BlocProvider<SearchCubit>(
create: (_) =>
SearchCubit()..addFilter(PostedByFilter(author: item.by)),
child: SizedBox(
height: MediaQuery.of(context).size.height - Dimens.pt120,
child: const Column(
children: <Widget>[
Expanded(child: SearchScreen(isInBottomSheet: true)),
],
),
),
return DraggableScrollableSheet(
expand: false,
initialChildSize: 0.9,
maxChildSize: 0.9,
minChildSize: 0.7,
builder: (BuildContext context, ScrollController scrollController) {
return BlocProvider<SearchCubit>(
create: (_) =>
SearchCubit()..addFilter(PostedByFilter(author: item.by)),
child: SearchScreen(
isInBottomSheet: true,
scrollController: scrollController,
),
);
},
);
},
);
Expand Down
1 change: 1 addition & 0 deletions lib/screens/item/widgets/time_machine_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TimeMachineDialog extends StatelessWidget {
Expanded(
child: ListView(
controller: scrollController,
physics: const ClampingScrollPhysics(),
children: <Widget>[
switch (rootItem) {
Story() => StoryTile(
Expand Down
26 changes: 22 additions & 4 deletions lib/screens/search/search_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,28 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:scrolls_to_top/scrolls_to_top.dart';

class SearchScreen extends StatefulWidget {
const SearchScreen({super.key, this.isInBottomSheet = false});
const SearchScreen({
super.key,
this.isInBottomSheet = false,
this.scrollController,
}) : assert(
!isInBottomSheet || scrollController != null,
'''ScrollController should be assigned when search screen is presented inside a sheet.''',
);

/// If user is viewing [SearchScreen] in bottom sheet,
/// we navigate to [ItemScreen] directly instead of injecting the
/// item into [SplitViewCubit].
final bool isInBottomSheet;
final ScrollController? scrollController;

@override
_SearchScreenState createState() => _SearchScreenState();
}

class _SearchScreenState extends State<SearchScreen> with ItemActionMixin {
final RefreshController refreshController = RefreshController();
final ScrollController scrollController = ScrollController();
late final ScrollController scrollController;
final FocusNode focusNode = FocusNode();
final Debouncer debouncer = Debouncer(delay: AppDurations.oneSecond);

Expand All @@ -36,13 +44,22 @@ class _SearchScreenState extends State<SearchScreen> with ItemActionMixin {
@override
void initState() {
super.initState();
scrollController = widget.scrollController ?? ScrollController();
scrollController.addListener(onScroll);
}

@override
void dispose() {
scrollController.removeListener(onScroll);

/// Do not dispose the scroll controller if it is being passed in from
/// the builder func of draggable scrollable sheet. It will be disposed
/// by the sheet.
if (!widget.isInBottomSheet) {
scrollController.dispose();
}

refreshController.dispose();
scrollController.dispose();
focusNode
..unfocus()
..dispose();
Expand Down Expand Up @@ -71,6 +88,7 @@ class _SearchScreenState extends State<SearchScreen> with ItemActionMixin {
children: <Widget>[
Expanded(
child: SmartRefresher(
physics: const ClampingScrollPhysics(),
scrollController: scrollController,
enablePullDown: false,
enablePullUp: true,
Expand Down Expand Up @@ -108,7 +126,7 @@ class _SearchScreenState extends State<SearchScreen> with ItemActionMixin {
child: ListView(
physics: state.results.isEmpty
? const NeverScrollableScrollPhysics()
: null,
: const ClampingScrollPhysics(),
children: <Widget>[
Column(
children: <Widget>[
Expand Down
7 changes: 3 additions & 4 deletions lib/screens/widgets/onboarding_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ class _OnboardingViewState extends State<OnboardingView> {
children: const <Widget>[
_PageViewChild(
path: Constants.commentTileRightSlidePath,
description:
'''Swipe right to leave a comment, vote, and more.''',
description: '''Swipe right to reply, vote, and more.''',
),
_PageViewChild(
path: Constants.commentTileLeftSlidePath,
description:
'''Swipe left to view all the ancestor comments.''',
'''Swipe left to view all ancestor comments.''',
),
_PageViewChild(
path: Constants.commentTileTopTapPath,
description:
'''Tap on anywhere inside a comment tile to collapse. Long press any link to copy.''',
'''Tap anywhere on a comment to collapse it. Long press any link to copy it.''',
),
],
),
Expand Down
26 changes: 15 additions & 11 deletions lib/services/dialog_proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ abstract final class DialogProxy {
isScrollControlled: true,
showDragHandle: true,
builder: (BuildContext context) {
return BlocProvider<SearchCubit>(
create: (_) => SearchCubit()..search(text),
child: SizedBox(
height: MediaQuery.of(context).size.height - Dimens.pt120,
child: const Column(
children: <Widget>[
Expanded(child: SearchScreen(isInBottomSheet: true)),
],
),
),
return DraggableScrollableSheet(
expand: false,
initialChildSize: 0.9,
maxChildSize: 0.9,
minChildSize: 0.7,
builder: (BuildContext context, ScrollController scrollController) {
return BlocProvider<SearchCubit>(
create: (_) => SearchCubit()..search(text),
child: SearchScreen(
isInBottomSheet: true,
scrollController: scrollController,
),
);
},
);
},
);
Expand All @@ -72,7 +76,7 @@ abstract final class DialogProxy {
expand: false,
initialChildSize: 0.9,
maxChildSize: 0.9,
minChildSize: 0.85,
minChildSize: 0.7,
builder: (BuildContext context, ScrollController scrollController) {
return TimeMachineDialog(
comment: comment,
Expand Down