Skip to content

Commit 06e038f

Browse files
authored
Merge pull request #18 from iwannet/main
Fix tap navigation to support pinch-to-zoom
2 parents 1b4f3aa + 8226354 commit 06e038f

4 files changed

Lines changed: 125 additions & 42 deletions

File tree

.github/workflows/release.yml

Lines changed: 71 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ name: Build and Release APKs
33
on:
44
release:
55
types: [created]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to build (e.g., 1.0.11, leave empty to use pubspec.yaml)'
10+
required: false
11+
default: ''
12+
skip_tests:
13+
description: 'Skip running tests'
14+
required: false
15+
default: false
16+
type: boolean
617

718
jobs:
819
build-and-release:
@@ -62,33 +73,67 @@ jobs:
6273
echo "Analysis completed successfully!"
6374
6475
- name: Run tests
76+
if: ${{ !inputs.skip_tests }}
6577
run: |
6678
echo "Running Flutter tests..."
6779
flutter test
6880
echo "Tests completed successfully!"
6981
7082
- name: Update pubspec version
7183
run: |
72-
# Extract version from tag (e.g., v1.2.3 -> 1.2.3, also handles 1.2.3)
73-
TAG_VERSION=$(echo "$GITHUB_REF_NAME" | sed 's/^v//')
84+
# For workflow_dispatch, use input version or keep current
85+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
86+
INPUT_VERSION="${{ inputs.version }}"
87+
if [[ -n "$INPUT_VERSION" ]]; then
88+
# Use the provided version
89+
TAG_VERSION="$INPUT_VERSION"
90+
91+
# Fix: If version is format 1.2, append .0 to make it 1.2.0
92+
if [[ "$TAG_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
93+
TAG_VERSION="${TAG_VERSION}.0"
94+
echo "Formatted version to semantic version: $TAG_VERSION"
95+
fi
96+
97+
# Validate version format
98+
if [[ ! "$TAG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
99+
echo "Error: Invalid version format: $TAG_VERSION"
100+
echo "Expected semantic version format (e.g., 1.2.3)"
101+
exit 1
102+
fi
103+
104+
# Use run_number as build number
105+
BUILD_NUMBER=${{ github.run_number }}
106+
# Update version in pubspec.yaml
107+
sed -i "s/^version: .*/version: ${TAG_VERSION}+${BUILD_NUMBER}/" pubspec.yaml
108+
echo "Updated version to: $TAG_VERSION+$BUILD_NUMBER"
109+
else
110+
echo "No version specified, using current version from pubspec.yaml"
111+
CURRENT_VERSION=$(grep "^version:" pubspec.yaml | sed 's/^version: //')
112+
echo "Current version: $CURRENT_VERSION"
113+
fi
114+
else
115+
# For release events, extract version from tag
116+
# Extract version from tag (e.g., v1.2.3 -> 1.2.3, also handles 1.2.3)
117+
TAG_VERSION=$(echo "$GITHUB_REF_NAME" | sed 's/^v//')
74118
75-
# Fix: If version is format 1.2, append .0 to make it 1.2.0
76-
if [[ "$TAG_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
77-
TAG_VERSION="${TAG_VERSION}.0"
78-
echo "Formatted version to semantic version: $TAG_VERSION"
79-
fi
119+
# Fix: If version is format 1.2, append .0 to make it 1.2.0
120+
if [[ "$TAG_VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
121+
TAG_VERSION="${TAG_VERSION}.0"
122+
echo "Formatted version to semantic version: $TAG_VERSION"
123+
fi
80124
81-
# Validate version format
82-
if [[ ! "$TAG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
83-
echo "Error: Invalid version format: $TAG_VERSION"
84-
echo "Expected semantic version format (e.g., 1.2.3)"
85-
exit 1
125+
# Validate version format
126+
if [[ ! "$TAG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
127+
echo "Error: Invalid version format: $TAG_VERSION"
128+
echo "Expected semantic version format (e.g., 1.2.3)"
129+
exit 1
130+
fi
131+
# Use run_number as build number
132+
BUILD_NUMBER=${{ github.run_number }}
133+
# Update version in pubspec.yaml
134+
sed -i "s/^version: .*/version: ${TAG_VERSION}+${BUILD_NUMBER}/" pubspec.yaml
135+
echo "Updated version to: $TAG_VERSION+$BUILD_NUMBER"
86136
fi
87-
# Use run_number as build number
88-
BUILD_NUMBER=${{ github.run_number }}
89-
# Update version in pubspec.yaml
90-
sed -i "s/^version: .*/version: ${TAG_VERSION}+${BUILD_NUMBER}/" pubspec.yaml
91-
echo "Updated version to: $TAG_VERSION+$BUILD_NUMBER"
92137
grep "^version:" pubspec.yaml
93138
94139
- name: Build all APKs
@@ -104,8 +149,17 @@ jobs:
104149
mv build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk release-artifacts/openlib-extended-armeabi-v7a-release.apk
105150
106151
- name: Upload Release Assets
152+
if: github.event_name == 'release'
107153
uses: softprops/action-gh-release@v1
108154
with:
109155
files: release-artifacts/*.apk
110156
env:
111157
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
159+
- name: Upload Build Artifacts
160+
if: github.event_name == 'workflow_dispatch'
161+
uses: actions/upload-artifact@v4
162+
with:
163+
name: apk-builds
164+
path: release-artifacts/*.apk
165+
retention-days: 7

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ To manually retry a failed build in GitHub Actions:
141141

142142
Alternatively, you can trigger a new release build by creating a new release tag.
143143

144+
### Manual Build (Without Release)
145+
146+
You can manually trigger a build without creating a release to test your changes:
147+
148+
1. Go to the [Actions tab](https://github.com/warreth/OpenlibExtended/actions) in the repository
149+
2. Click on "Build and Release APKs" workflow on the left sidebar
150+
3. Click "Run workflow" button (top right)
151+
4. Optionally:
152+
- Enter a version number (e.g., 1.0.12) or leave empty to use current version from pubspec.yaml
153+
- Check "Skip running tests" if you want to skip tests
154+
5. Click the green "Run workflow" button
155+
6. Wait for the build to complete
156+
7. Download the APK artifacts from the workflow run page
157+
144158
### Android
145159

146160
Make sure that `android/local.properties` has `flutter.minSdkVersion=21` or above

lib/ui/epub_viewer.dart

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class EpubViewer extends ConsumerStatefulWidget {
112112
class _EpubViewerState extends ConsumerState<EpubViewer> {
113113
late EpubController _epubReaderController;
114114
String? epubConf;
115+
final Set<int> _activePointers = {};
115116

116117
@override
117118
void initState() {
@@ -218,22 +219,29 @@ class _EpubViewerState extends ConsumerState<EpubViewer> {
218219
children: [
219220
child,
220221
Positioned.fill(
221-
child: GestureDetector(
222+
child: Listener(
222223
behavior: HitTestBehavior.translucent,
223-
onTapUp: (details) {
224-
final screenWidth = MediaQuery.of(context).size.width;
225-
final tapPosition = details.globalPosition.dx;
224+
onPointerDown: (event) => _activePointers.add(event.pointer),
225+
onPointerUp: (event) {
226+
_activePointers.remove(event.pointer);
226227

227-
// Divide screen into three zones: left (30%), center (40%), right (30%)
228-
if (tapPosition < screenWidth * 0.3) {
229-
// Left zone - previous chapter
230-
_navigateToPreviousChapter();
231-
} else if (tapPosition > screenWidth * 0.7) {
232-
// Right zone - next chapter
233-
_navigateToNextChapter();
228+
// Only handle navigation on single-finger taps
229+
if (_activePointers.isEmpty) {
230+
final screenWidth = MediaQuery.of(context).size.width;
231+
final tapPosition = event.position.dx;
232+
233+
// Divide screen into three zones: left (30%), center (40%), right (30%)
234+
if (tapPosition < screenWidth * 0.3) {
235+
// Left zone - previous chapter
236+
_navigateToPreviousChapter();
237+
} else if (tapPosition > screenWidth * 0.7) {
238+
// Right zone - next chapter
239+
_navigateToNextChapter();
240+
}
241+
// Center zone (30-70%) - no action, allows text selection
234242
}
235-
// Center zone (30-70%) - no action, allows text selection
236243
},
244+
onPointerCancel: (event) => _activePointers.remove(event.pointer),
237245
child: Container(color: Colors.transparent),
238246
),
239247
),

lib/ui/pdf_viewer.dart

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class PdfViewer extends ConsumerStatefulWidget {
9595

9696
class _PdfViewerState extends ConsumerState<PdfViewer> {
9797
late PDFViewController controller;
98+
final Set<int> _activePointers = {};
9899

99100
@override
100101
void initState() {
@@ -262,23 +263,29 @@ class _PdfViewerState extends ConsumerState<PdfViewer> {
262263
children: [
263264
child,
264265
Positioned.fill(
265-
child: GestureDetector(
266+
child: Listener(
266267
behavior: HitTestBehavior.translucent,
267-
onTapUp: (details) {
268-
final screenWidth = MediaQuery.of(context).size.width;
269-
final tapPosition = details.globalPosition.dx;
268+
onPointerDown: (event) => _activePointers.add(event.pointer),
269+
onPointerUp: (event) {
270+
_activePointers.remove(event.pointer);
270271

271-
// Divide screen into three zones: left (30%), center (40%), right (30%)
272-
if (tapPosition < screenWidth * 0.3) {
273-
// Left zone - previous page
274-
_goToPreviousPage();
275-
} else if (tapPosition > screenWidth * 0.7) {
276-
// Right zone - next page
277-
_goToNextPage();
272+
// Only handle navigation on single-finger taps
273+
if (_activePointers.isEmpty) {
274+
final screenWidth = MediaQuery.of(context).size.width;
275+
final tapPosition = event.position.dx;
276+
277+
// Divide screen into three zones: left (30%), center (40%), right (30%)
278+
if (tapPosition < screenWidth * 0.3) {
279+
// Left zone - previous page
280+
_goToPreviousPage();
281+
} else if (tapPosition > screenWidth * 0.7) {
282+
// Right zone - next page
283+
_goToNextPage();
284+
}
285+
// Center zone (30-70%) - no action, allows zooming and other interactions
278286
}
279-
// Center zone (30-70%) - no action, allows zooming and other interactions
280287
},
281-
// This child is transparent to allow underlying PDF gestures (like zoom) to work
288+
onPointerCancel: (event) => _activePointers.remove(event.pointer),
282289
child: Container(color: Colors.transparent),
283290
),
284291
),

0 commit comments

Comments
 (0)