Skip to content

Commit 3413b16

Browse files
authored
fix: double tap instead of long press to open url. (#478)
1 parent c24670d commit 3413b16

File tree

5 files changed

+55
-19
lines changed

5 files changed

+55
-19
lines changed

lib/models/preference.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ final class SwipeGesturePreference extends BooleanPreference {
110110
String get key => 'swipeGestureMode';
111111

112112
@override
113-
String get title => 'Swipe Gesture';
113+
String get title => 'Swipe Gesture for Switching Tabs';
114114

115115
@override
116116
String get subtitle =>
117-
'''enable swipe gesture for switching between tabs. If enabled, long press on Story tile to trigger the action menu.''';
117+
'''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).''';
118118
}
119119

120120
final class NotificationModePreference extends BooleanPreference {

lib/screens/widgets/items_list_view.dart

+7
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ class ItemsListView<T extends Item> extends StatelessWidget {
8282
FadeIn(
8383
child: InkWell(
8484
onTap: () => onTap(e),
85+
86+
/// If swipe gesture is enabled on home screen, use
87+
/// long press instead of slide action to trigger
88+
/// the action menu.
89+
onLongPress: swipeGestureEnabled
90+
? () => onMoreTapped?.call(e, context.rect)
91+
: null,
8592
child: Padding(
8693
padding: const EdgeInsets.only(
8794
top: Dimens.pt8,

lib/screens/widgets/link_preview/link_view.dart

+44-15
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,41 @@ class LinkView extends StatelessWidget {
123123
),
124124
),
125125
)
126-
: CachedNetworkImage(
127-
imageUrl: imageUri ?? Constants.favicon(url),
128-
fit: isIcon ? BoxFit.scaleDown : BoxFit.fitWidth,
129-
cacheKey: imageUri,
130-
errorWidget: (_, __, ___) {
131-
if (url.isEmpty) {
132-
return FadeIn(
133-
child: Center(
134-
child: _HackerNewsImage(
135-
height: layoutHeight,
126+
: () {
127+
if (imageUri?.isNotEmpty ?? false) {
128+
return CachedNetworkImage(
129+
imageUrl: imageUri!,
130+
fit:
131+
isIcon ? BoxFit.scaleDown : BoxFit.fitWidth,
132+
cacheKey: imageUri,
133+
errorWidget: (_, __, ___) {
134+
if (url.isEmpty) {
135+
return FadeIn(
136+
child: Center(
137+
child: _HackerNewsImage(
138+
height: layoutHeight,
139+
),
140+
),
141+
);
142+
}
143+
return Center(
144+
child: CachedNetworkImage(
145+
imageUrl: Constants.favicon(url),
146+
fit: BoxFit.scaleDown,
147+
cacheKey: iconUri,
148+
errorWidget: (_, __, ___) {
149+
return const FadeIn(
150+
child: Icon(
151+
Icons.public,
152+
size: Dimens.pt20,
153+
),
154+
);
155+
},
136156
),
137-
),
138-
);
139-
}
157+
);
158+
},
159+
);
160+
} else if (url.isNotEmpty) {
140161
return Center(
141162
child: CachedNetworkImage(
142163
imageUrl: Constants.favicon(url),
@@ -152,8 +173,16 @@ class LinkView extends StatelessWidget {
152173
},
153174
),
154175
);
155-
},
156-
),
176+
} else {
177+
return FadeIn(
178+
child: Center(
179+
child: _HackerNewsImage(
180+
height: layoutHeight,
181+
),
182+
),
183+
);
184+
}
185+
}(),
157186
),
158187
),
159188
)

lib/screens/widgets/story_tile.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class StoryTile extends StatelessWidget {
128128
excludeSemantics: true,
129129
child: InkWell(
130130
onTap: onTap,
131-
onLongPress: () {
131+
onDoubleTap: () {
132132
if (story.url.isNotEmpty) {
133133
LinkUtil.launch(
134134
story.url,

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: hacki
22
description: A Hacker News reader.
3-
version: 2.9.2+150
3+
version: 2.9.3+151
44
publish_to: none
55

66
environment:

0 commit comments

Comments
 (0)