Skip to content

Commit

Permalink
fix: double tap instead of long press to open url. (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
Livinglist authored Sep 20, 2024
1 parent c24670d commit 3413b16
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/models/preference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ final class SwipeGesturePreference extends BooleanPreference {
String get key => 'swipeGestureMode';

@override
String get title => 'Swipe Gesture';
String get title => 'Swipe Gesture for Switching Tabs';

@override
String get subtitle =>
'''enable swipe gesture for switching between tabs. If enabled, long press on Story tile to trigger the action menu.''';
'''enable swipe gesture for switching between tabs. If enabled, long press on Story tile to trigger the action menu and double tap to open the url (if complex tile is disabled).''';
}

final class NotificationModePreference extends BooleanPreference {
Expand Down
7 changes: 7 additions & 0 deletions lib/screens/widgets/items_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ class ItemsListView<T extends Item> extends StatelessWidget {
FadeIn(
child: InkWell(
onTap: () => onTap(e),

/// If swipe gesture is enabled on home screen, use
/// long press instead of slide action to trigger
/// the action menu.
onLongPress: swipeGestureEnabled
? () => onMoreTapped?.call(e, context.rect)
: null,
child: Padding(
padding: const EdgeInsets.only(
top: Dimens.pt8,
Expand Down
59 changes: 44 additions & 15 deletions lib/screens/widgets/link_preview/link_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,41 @@ class LinkView extends StatelessWidget {
),
),
)
: CachedNetworkImage(
imageUrl: imageUri ?? Constants.favicon(url),
fit: isIcon ? BoxFit.scaleDown : BoxFit.fitWidth,
cacheKey: imageUri,
errorWidget: (_, __, ___) {
if (url.isEmpty) {
return FadeIn(
child: Center(
child: _HackerNewsImage(
height: layoutHeight,
: () {
if (imageUri?.isNotEmpty ?? false) {
return CachedNetworkImage(
imageUrl: imageUri!,
fit:
isIcon ? BoxFit.scaleDown : BoxFit.fitWidth,
cacheKey: imageUri,
errorWidget: (_, __, ___) {
if (url.isEmpty) {
return FadeIn(
child: Center(
child: _HackerNewsImage(
height: layoutHeight,
),
),
);
}
return Center(
child: CachedNetworkImage(
imageUrl: Constants.favicon(url),
fit: BoxFit.scaleDown,
cacheKey: iconUri,
errorWidget: (_, __, ___) {
return const FadeIn(
child: Icon(
Icons.public,
size: Dimens.pt20,
),
);
},
),
),
);
}
);
},
);
} else if (url.isNotEmpty) {
return Center(
child: CachedNetworkImage(
imageUrl: Constants.favicon(url),
Expand All @@ -152,8 +173,16 @@ class LinkView extends StatelessWidget {
},
),
);
},
),
} else {
return FadeIn(
child: Center(
child: _HackerNewsImage(
height: layoutHeight,
),
),
);
}
}(),
),
),
)
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/widgets/story_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class StoryTile extends StatelessWidget {
excludeSemantics: true,
child: InkWell(
onTap: onTap,
onLongPress: () {
onDoubleTap: () {
if (story.url.isNotEmpty) {
LinkUtil.launch(
story.url,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: hacki
description: A Hacker News reader.
version: 2.9.2+150
version: 2.9.3+151
publish_to: none

environment:
Expand Down

0 comments on commit 3413b16

Please sign in to comment.