Compare commits

...

5 Commits

23 changed files with 382 additions and 81 deletions

46
.dockerignore Normal file
View File

@ -0,0 +1,46 @@
# Prevent leaking host-specific caches/paths into the image
.dockerignore
.git
.gitignore
.idea
.vscode
**/.DS_Store
build/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
pubspec.lock # keep if you want reproducible, comment out to include
# Flutter/Platform build outputs
android/
ios/
linux/
macos/
windows/
web/.dart_tool/
# Tests and dev artifacts (optional, not needed in image build stage)
test/
integration_test/
coverage/
custom_lint.log
test_cache/
unit_test_assets/
# Docs and repo meta to avoid cache busting
docs/
**/*.md
wireframe.assets/
AGENTS.md
README.md
LICENSE
# Packaging artifacts not needed for web image
AppDir/
AppRun
pdf_signature.desktop
tool/
*.iml
*.ipr
*.iws
.github/
.husky/

93
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,93 @@
name: Publish Docker image
on:
push:
branches: [ "main" ]
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
name: Build and push image
runs-on: ubuntu-latest
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU (for multi-arch builds)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', 'pubspec.lock') }}
restore-keys: |
${{ runner.os }}-buildx-
# Docker Hub login (active)
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# GHCR login (commented out for future usage)
# - name: Log in to GitHub Container Registry
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
if: always()
run: |
if [ -d /tmp/.buildx-cache-new ]; then
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
else
echo "No new cache to move"
fi

1
.gitignore vendored
View File

@ -125,6 +125,7 @@ devtools_options.yaml
test/features/*_test.dart
**/app_localizations*.dart
.env
.secrets
docs/wireframe.assets/*.excalidraw.svg
docs/wireframe.assets/*.svg
docs/wireframe.assets/*.png

54
Dockerfile Normal file
View File

@ -0,0 +1,54 @@
# syntax=docker/dockerfile:1.7-labs
## Two-stage build for minimal Flutter web static server (Caddy runtime)
# Stage 1: Build the Flutter web app
FROM ghcr.io/cirruslabs/flutter:latest AS build
WORKDIR /app
# Copy pubspec first for better layer caching
COPY pubspec.* ./
# Use BuildKit cache for Dart pub cache
RUN --mount=type=cache,target=/root/.pub-cache \
flutter pub get
# Copy the rest of the project
COPY . .
# Ensure no host caches leak into the container; use BuildKit caches for pub and Flutter
RUN --mount=type=cache,target=/root/.pub-cache \
--mount=type=cache,target=/sdks/flutter/bin/cache \
rm -rf .dart_tool build && \
flutter pub get && \
flutter gen-l10n && \
flutter build web --release -O4 --wasm
# Stage 2: Caddy (Alpine) to serve static files with SPA fallback
FROM caddy:2-alpine AS runtime
WORKDIR /usr/share/caddy
# Copy built web assets
COPY --from=build /app/build/web/ /usr/share/caddy/
# Write Caddyfile inline (listens on :8080 and SPA fallback)
ENV PORT=8080
RUN cat > /etc/caddy/Caddyfile <<'CADDY'
{
admin off
}
:{$PORT} {
root * /usr/share/caddy
encode zstd gzip
# SPA fallback: serve index.html if file not found
try_files {path} /index.html
file_server
}
CADDY
# Some platforms (e.g., gVisor/Firecracker like Render) forbid file capabilities; strip and copy to a clean path
USER root
RUN apk add --no-cache libcap && \
(setcap -r /usr/bin/caddy || true) && \
install -m 0755 /usr/bin/caddy /caddy && \
apk del libcap
# Use numeric UID/GID for caddy to avoid passwd lookup issues across platforms
USER 65532:65532
EXPOSE 8080
ENTRYPOINT ["/caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]

View File

@ -21,13 +21,13 @@ flutter analyze
# > run unit tests and widget tests
flutter test
# > run integration tests
flutter test integration_test/ -d linux
flutter test integration_test/ -d <device_id>
# dart run tool/gen_view_wireframe_md.dart
# flutter pub run dead_code_analyzer
# run the app
flutter run
flutter run -d <device_id>
```
### build
@ -39,13 +39,33 @@ flutter build windows
flutter pub run msix:create
```
For web
#### web
```bash
flutter build web
# flutter build web --release -O4 --wasm
```
Open the `index.html` file in the `build/web` directory. Remove the `<base href="/">` to ensure proper routing on GitHub Pages.
##### Docker
To build and run a minimal Docker image serving static Flutter web files:
```bash
# Build the Docker image
docker build -t pdf_signature .
# Run the container (serves static files on port 8080)
docker run --rm -p 8080:8080 pdf_signature
# act push -P ubuntu-latest=catthehacker/ubuntu:act-latest --container-options "--privileged" --env-file .env --secret-file .secrets
```
Access your app at [http://localhost:8080](http://localhost:8080)
#### Linux
For Linux
```bash
flutter build linux
cp -r build/linux/x64/release/bundle/ AppDir

View File

@ -45,6 +45,7 @@ void main() {
child: const MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: Locale('en'),
home: PdfSignatureHomePage(),
),
),
@ -96,6 +97,7 @@ void main() {
child: const MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
locale: Locale('en'),
home: PdfSignatureHomePage(),
),
),

View File

@ -2,6 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:path_provider/path_provider.dart' as pp;
import 'package:file_selector/file_selector.dart' as fs;
import 'package:pdf_signature/data/services/export_service.dart';
import 'package:pdf_signature/data/services/preferences_providers.dart';
// Feature-scoped DI and configuration providers
@ -11,8 +12,19 @@ final useMockViewerProvider = Provider<bool>((_) => false);
// Export service injection for testability
final exportServiceProvider = Provider<ExportService>((_) => ExportService());
// Export DPI setting (points per inch mapping), default 144 DPI
final exportDpiProvider = StateProvider<double>((_) => 144.0);
// Export DPI setting (points per inch mapping). Reads from SharedPreferences when available,
// otherwise falls back to 144.0 to keep tests deterministic without bootstrapping prefs.
final exportDpiProvider = Provider<double>((ref) {
final sp = ref.watch(sharedPreferencesProvider);
return sp.maybeWhen(
data: (prefs) {
const allowed = [96.0, 144.0, 200.0, 300.0];
final v = prefs.getDouble('export_dpi');
return (v != null && allowed.contains(v)) ? v : 144.0;
},
orElse: () => 144.0,
);
});
// Controls whether signature overlay is visible (used to hide on non-stamped pages during export)
final signatureVisibilityProvider = StateProvider<bool>((_) => true);

View File

@ -29,6 +29,7 @@ Set<String> _supportedTags() {
const _kTheme = 'theme'; // 'light'|'dark'|'system'
const _kLanguage = 'language'; // BCP-47 tag like 'en', 'zh-TW', 'es'
const _kPageView = 'page_view'; // now only 'continuous'
const _kExportDpi = 'export_dpi'; // double, allowed: 96,144,200,300
String _normalizeLanguageTag(String tag) {
final tags = _supportedTags();
@ -66,20 +67,24 @@ class PreferencesState {
final String theme; // 'light' | 'dark' | 'system'
final String language; // 'en' | 'zh-TW' | 'es'
final String pageView; // only 'continuous'
final double exportDpi; // 96.0 | 144.0 | 200.0 | 300.0
const PreferencesState({
required this.theme,
required this.language,
required this.pageView,
required this.exportDpi,
});
PreferencesState copyWith({
String? theme,
String? language,
String? pageView,
double? exportDpi,
}) => PreferencesState(
theme: theme ?? this.theme,
language: language ?? this.language,
pageView: pageView ?? this.pageView,
exportDpi: exportDpi ?? this.exportDpi,
);
}
@ -95,12 +100,20 @@ class PreferencesNotifier extends StateNotifier<PreferencesState> {
.toLanguageTag(),
),
pageView: prefs.getString(_kPageView) ?? 'continuous',
exportDpi: _readDpi(prefs),
),
) {
// normalize language to supported/fallback
_ensureValid();
}
static double _readDpi(SharedPreferences prefs) {
final d = prefs.getDouble(_kExportDpi);
if (d == null) return 144.0;
const allowed = [96.0, 144.0, 200.0, 300.0];
return allowed.contains(d) ? d : 144.0;
}
void _ensureValid() {
final themeValid = {'light', 'dark', 'system'};
if (!themeValid.contains(state.theme)) {
@ -117,6 +130,12 @@ class PreferencesNotifier extends StateNotifier<PreferencesState> {
state = state.copyWith(pageView: 'continuous');
prefs.setString(_kPageView, 'continuous');
}
// Ensure DPI is one of allowed values
const allowed = [96.0, 144.0, 200.0, 300.0];
if (!allowed.contains(state.exportDpi)) {
state = state.copyWith(exportDpi: 144.0);
prefs.setDouble(_kExportDpi, 144.0);
}
}
Future<void> setTheme(String theme) async {
@ -140,10 +159,12 @@ class PreferencesNotifier extends StateNotifier<PreferencesState> {
theme: 'system',
language: normalized,
pageView: 'continuous',
exportDpi: 144.0,
);
await prefs.setString(_kTheme, 'system');
await prefs.setString(_kLanguage, normalized);
await prefs.setString(_kPageView, 'continuous');
await prefs.setDouble(_kExportDpi, 144.0);
}
Future<void> setPageView(String pageView) async {
@ -152,6 +173,13 @@ class PreferencesNotifier extends StateNotifier<PreferencesState> {
state = state.copyWith(pageView: pageView);
await prefs.setString(_kPageView, pageView);
}
Future<void> setExportDpi(double dpi) async {
const allowed = [96.0, 144.0, 200.0, 300.0];
if (!allowed.contains(dpi)) return;
state = state.copyWith(exportDpi: dpi);
await prefs.setDouble(_kExportDpi, dpi);
}
}
final sharedPreferencesProvider = FutureProvider<SharedPreferences>((

View File

@ -11,7 +11,7 @@
"delete": "Löschen",
"display": "Anzeige",
"downloadStarted": "Download gestartet",
"dpi": "DPI:",
"dpi": "DPI",
"drawSignature": "Signatur zeichnen",
"errorWithMessage": "Fehler: {message}",
"exportingPleaseWait": "Exportiere… Bitte warten",
@ -19,6 +19,7 @@
"failedToSavePdf": "PDF konnte nicht gespeichert werden",
"general": "Allgemein",
"goTo": "Gehe zu:",
"image": "Bild",
"invalidOrUnsupportedFile": "Ungültige oder nicht unterstützte Datei",
"language": "Sprache",
"loadSignatureFromFile": "Signatur aus Datei laden",
@ -34,6 +35,7 @@
"pageViewContinuous": "Kontinuierlich",
"prev": "Vorherige",
"resetToDefaults": "Auf Standardwerte zurücksetzen",
"rotate": "Drehen",
"save": "Speichern",
"savedWithPath": "Gespeichert: {path}",
"saveSignedPdf": "Signiertes PDF speichern",

View File

@ -24,7 +24,7 @@
"@display": {},
"downloadStarted": "Download started",
"@downloadStarted": {},
"dpi": "DPI:",
"dpi": "DPI",
"@dpi": {},
"drawSignature": "Draw Signature",
"@drawSignature": {},
@ -47,6 +47,8 @@
"@general": {},
"goTo": "Go to:",
"@goTo": {},
"image": "Image",
"@image": {},
"invalidOrUnsupportedFile": "Invalid or unsupported file",
"@invalidOrUnsupportedFile": {},
"language": "Language",
@ -87,6 +89,8 @@
"@prev": {},
"resetToDefaults": "Reset to defaults",
"@resetToDefaults": {},
"rotate": "Rotate",
"@rotate": {},
"save": "Save",
"@save": {},
"savedWithPath": "Saved: {path}",

View File

@ -11,7 +11,7 @@
"delete": "Eliminar",
"display": "Pantalla",
"downloadStarted": "Descarga iniciada",
"dpi": "DPI:",
"dpi": "DPI",
"drawSignature": "Dibujar firma",
"errorWithMessage": "Error: {message}",
"exportingPleaseWait": "Exportando... Por favor, espere",
@ -19,6 +19,7 @@
"failedToSavePdf": "No se pudo guardar el PDF",
"general": "General",
"goTo": "Ir a:",
"image": "Imagen",
"invalidOrUnsupportedFile": "Archivo inválido o no compatible",
"language": "Idioma",
"loadSignatureFromFile": "Cargar firma desde archivo",
@ -34,6 +35,7 @@
"pageViewContinuous": "Continuo",
"prev": "Anterior",
"resetToDefaults": "Restablecer valores predeterminados",
"rotate": "Rotar",
"save": "Guardar",
"savedWithPath": "Guardado: {path}",
"saveSignedPdf": "Guardar PDF firmado",

View File

@ -19,6 +19,7 @@
"failedToSavePdf": "Échec de l'enregistrement du PDF",
"general": "Général",
"goTo": "Aller à :",
"image": "Image",
"invalidOrUnsupportedFile": "Fichier invalide ou non pris en charge",
"language": "Langue",
"loadSignatureFromFile": "Charger une signature depuis un fichier",
@ -34,6 +35,7 @@
"pageViewContinuous": "Continu",
"prev": "Précédent",
"resetToDefaults": "Rétablir les valeurs par défaut",
"rotate": "Rotation",
"save": "Enregistrer",
"savedWithPath": "Enregistré : {path}",
"saveSignedPdf": "Enregistrer le PDF signé",

View File

@ -11,7 +11,7 @@
"delete": "削除",
"display": "表示",
"downloadStarted": "ダウンロード開始",
"dpi": "DPI",
"dpi": "DPI",
"drawSignature": "署名をかく",
"errorWithMessage": "エラー:{message}",
"exportingPleaseWait": "エクスポート中…お待ちください",
@ -19,6 +19,7 @@
"failedToSavePdf": "PDFの保存に失敗しました",
"general": "一般",
"goTo": "移動:",
"image": "画像",
"invalidOrUnsupportedFile": "無効なファイルまたはサポートされていないファイル",
"language": "言語",
"loadSignatureFromFile": "ファイルから署名を読み込む",
@ -34,6 +35,7 @@
"pageViewContinuous": "連続",
"prev": "前へ",
"resetToDefaults": "デフォルトに戻す",
"rotate": "回転",
"save": "保存",
"savedWithPath": "保存しました:{path}",
"saveSignedPdf": "署名済みPDFを保存",

View File

@ -11,7 +11,7 @@
"delete": "삭제",
"display": "표시",
"downloadStarted": "다운로드 시작됨",
"dpi": "DPI:",
"dpi": "DPI",
"drawSignature": "서명 그리기",
"errorWithMessage": "오류: {message}",
"exportingPleaseWait": "내보내는 중... 잠시 기다려주세요",
@ -19,6 +19,7 @@
"failedToSavePdf": "PDF 저장 실패",
"general": "일반",
"goTo": "이동:",
"image": "이미지",
"invalidOrUnsupportedFile": "잘못된 파일이거나 지원되지 않는 파일입니다.",
"language": "언어",
"loadSignatureFromFile": "파일에서 서명 불러오기",
@ -34,6 +35,7 @@
"pageViewContinuous": "연속",
"prev": "이전",
"resetToDefaults": "기본값으로 재설정",
"rotate": "회전",
"save": "저장",
"savedWithPath": "{path}에 저장됨",
"saveSignedPdf": "서명된 PDF 저장",

View File

@ -11,7 +11,7 @@
"delete": "Видалити",
"display": "Відображення",
"downloadStarted": "Завантаження розпочато",
"dpi": "DPI:",
"dpi": "DPI",
"drawSignature": "Намалювати підпис",
"errorWithMessage": "Помилка: {message}",
"exportingPleaseWait": "Експортування... Зачекайте",
@ -19,6 +19,7 @@
"failedToSavePdf": "Не вдалося зберегти PDF",
"general": "Загальні",
"goTo": "Перейти до:",
"image": "Зображення",
"invalidOrUnsupportedFile": "Недійсний або непідтримуваний файл",
"language": "Мова",
"loadSignatureFromFile": "Завантажити підпис з файлу",
@ -34,6 +35,7 @@
"pageViewContinuous": "Безперервний",
"prev": "Попередня",
"resetToDefaults": "Скинути до значень за замовчуванням",
"rotate": "Повернути",
"save": "Зберегти",
"savedWithPath": "Збережено: {path}",
"saveSignedPdf": "Зберегти підписаний PDF",

View File

@ -12,7 +12,7 @@
"delete": "刪除",
"display": "顯示",
"downloadStarted": "已開始下載",
"dpi": "DPI",
"dpi": "DPI",
"drawSignature": "手寫簽名",
"errorWithMessage": "錯誤:{message}",
"exportingPleaseWait": "匯出中…請稍候",
@ -20,6 +20,7 @@
"failedToSavePdf": "儲存 PDF 失敗",
"general": "一般",
"goTo": "前往:",
"image": "圖片",
"invalidOrUnsupportedFile": "無效或不支援的檔案",
"language": "語言",
"loadSignatureFromFile": "從檔案載入簽名",
@ -27,7 +28,7 @@
"longPressOrRightClickTheSignatureToConfirmOrDelete": "長按或右鍵點擊簽名以確認或刪除。",
"next": "下一頁",
"noPdfLoaded": "尚未載入 PDF",
"noSignatureLoaded": "没有加载签名",
"noSignatureLoaded": "沒有加載簽名",
"nothingToSaveYet": "尚無可儲存的內容",
"openPdf": "開啟 PDF…",
"pageInfo": "第 {current}/{total} 頁",
@ -35,6 +36,7 @@
"pageViewContinuous": "連續",
"prev": "上一頁",
"resetToDefaults": "重設為預設值",
"rotate": "旋轉",
"save": "儲存",
"savedWithPath": "已儲存:{path}",
"saveSignedPdf": "儲存已簽名 PDF",

View File

@ -11,7 +11,7 @@
"delete": "删除",
"display": "显示",
"downloadStarted": "下载已开始",
"dpi": "DPI",
"dpi": "DPI",
"drawSignature": "绘制签名",
"errorWithMessage": "错误:{message}",
"exportingPleaseWait": "正在导出... 请稍候",
@ -19,6 +19,7 @@
"failedToSavePdf": "PDF 保存失败",
"general": "常规",
"goTo": "跳转到:",
"image": "图片",
"invalidOrUnsupportedFile": "无效或不支持的文件",
"language": "语言",
"loadSignatureFromFile": "从文件加载签名",
@ -34,6 +35,7 @@
"pageViewContinuous": "连续",
"prev": "上一页",
"resetToDefaults": "恢复默认值",
"rotate": "旋转",
"save": "保存",
"savedWithPath": "已保存:{path}",
"saveSignedPdf": "保存已签名的 PDF",

View File

@ -12,7 +12,7 @@
"delete": "刪除",
"display": "顯示",
"downloadStarted": "已開始下載",
"dpi": "DPI",
"dpi": "DPI",
"drawSignature": "手寫簽名",
"errorWithMessage": "錯誤:{message}",
"exportingPleaseWait": "匯出中…請稍候",
@ -20,6 +20,7 @@
"failedToSavePdf": "儲存 PDF 失敗",
"general": "一般",
"goTo": "前往:",
"image": "圖片",
"invalidOrUnsupportedFile": "無效或不支援的檔案",
"language": "語言",
"loadSignatureFromFile": "從檔案載入簽名",
@ -35,6 +36,7 @@
"pageViewContinuous": "連續",
"prev": "上一頁",
"resetToDefaults": "重設為預設值",
"rotate": "旋轉",
"save": "儲存",
"savedWithPath": "已儲存:{path}",
"saveSignedPdf": "儲存已簽名 PDF",

View File

@ -4,6 +4,7 @@ import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:image/image.dart' as img;
import 'package:pdf_signature/l10n/app_localizations.dart';
import '../../../../data/model/model.dart';
@ -251,7 +252,14 @@ class SignatureController extends StateNotifier<SignatureState> {
void setInvalidSelected(BuildContext context) {
// Fallback message without localization to keep core logic testable
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Invalid or unsupported file')),
SnackBar(
content: Text(
Localizations.of<AppLocalizations>(
context,
AppLocalizations,
)!.invalidOrUnsupportedFile,
),
),
);
}

View File

@ -10,6 +10,8 @@ class ImageEditorDialog extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final l10n = Localizations.of<AppLocalizations>(context, AppLocalizations)!;
final l = AppLocalizations.of(context);
final sig = ref.watch(signatureProvider);
return Dialog(
@ -57,7 +59,7 @@ class ImageEditorDialog extends ConsumerWidget {
const SizedBox(height: 8),
Row(
children: [
Text('Rotate'),
Text(l10n.rotate),
Expanded(
child: Slider(
key: const Key('sld_rotation'),

View File

@ -68,8 +68,9 @@ class _PdfSignatureHomePageState extends ConsumerState<PdfSignatureHomePage> {
}
Future<Uint8List?> _loadSignatureFromFile() async {
final typeGroup = const fs.XTypeGroup(
label: 'Image',
final typeGroup = fs.XTypeGroup(
label:
Localizations.of<AppLocalizations>(context, AppLocalizations)?.image,
extensions: ['png', 'jpg', 'jpeg', 'webp'],
);
final file = await fs.openFile(acceptedTypeGroups: [typeGroup]);

View File

@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:pdf_signature/l10n/app_localizations.dart';
import '../../../../data/services/export_providers.dart';
import '../view_model/view_model.dart';
class PdfToolbar extends ConsumerStatefulWidget {
@ -57,7 +56,6 @@ class _PdfToolbarState extends ConsumerState<PdfToolbar> {
@override
Widget build(BuildContext context) {
final pdf = ref.watch(pdfProvider);
final dpi = ref.watch(exportDpiProvider);
final l = AppLocalizations.of(context);
final pageInfo = l.pageInfo(pdf.currentPage, pdf.pageCount);
@ -97,25 +95,32 @@ class _PdfToolbarState extends ConsumerState<PdfToolbar> {
Wrap(
spacing: 8,
children: [
IconButton(
key: const Key('btn_prev'),
onPressed:
widget.disabled
? null
: () => widget.onJumpToPage(pdf.currentPage - 1),
icon: const Icon(Icons.chevron_left),
tooltip: l.prev,
),
// Current page label
Text(pageInfo, key: const Key('lbl_page_info')),
IconButton(
key: const Key('btn_next'),
onPressed:
widget.disabled
? null
: () => widget.onJumpToPage(pdf.currentPage + 1),
icon: const Icon(Icons.chevron_right),
tooltip: l.next,
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
key: const Key('btn_prev'),
onPressed:
widget.disabled
? null
: () =>
widget.onJumpToPage(pdf.currentPage - 1),
icon: const Icon(Icons.chevron_left),
tooltip: l.prev,
),
// Current page label
Text(pageInfo, key: const Key('lbl_page_info')),
IconButton(
key: const Key('btn_next'),
onPressed:
widget.disabled
? null
: () =>
widget.onJumpToPage(pdf.currentPage + 1),
icon: const Icon(Icons.chevron_right),
tooltip: l.next,
),
],
),
Wrap(
spacing: 6,
@ -150,48 +155,29 @@ class _PdfToolbarState extends ConsumerState<PdfToolbar> {
],
),
const SizedBox(width: 8),
IconButton(
key: const Key('btn_zoom_out'),
tooltip: 'Zoom out',
onPressed: widget.disabled ? null : widget.onZoomOut,
icon: const Icon(Icons.zoom_out),
),
Text(
//if not null
widget.zoomLevel != null ? '${widget.zoomLevel}%' : '',
style: const TextStyle(fontSize: 12),
),
IconButton(
key: const Key('btn_zoom_in'),
tooltip: 'Zoom in',
onPressed: widget.disabled ? null : widget.onZoomIn,
icon: const Icon(Icons.zoom_in),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
key: const Key('btn_zoom_out'),
tooltip: 'Zoom out',
onPressed: widget.disabled ? null : widget.onZoomOut,
icon: const Icon(Icons.zoom_out),
),
Text(
//if not null
widget.zoomLevel != null ? '${widget.zoomLevel}%' : '',
style: const TextStyle(fontSize: 12),
),
IconButton(
key: const Key('btn_zoom_in'),
tooltip: 'Zoom in',
onPressed: widget.disabled ? null : widget.onZoomIn,
icon: const Icon(Icons.zoom_in),
),
],
),
SizedBox(width: 6),
// show zoom ratio
Text(l.dpi),
const SizedBox(width: 8),
DropdownButton<double>(
key: const Key('ddl_export_dpi'),
value: dpi,
items:
const [96.0, 144.0, 200.0, 300.0]
.map(
(v) => DropdownMenuItem(
value: v,
child: Text(v.toStringAsFixed(0)),
),
)
.toList(),
onChanged:
widget.disabled
? null
: (v) {
if (v != null) {
ref.read(exportDpiProvider.notifier).state = v;
}
},
),
],
),
],

View File

@ -14,6 +14,7 @@ class _SettingsDialogState extends ConsumerState<SettingsDialog> {
String? _theme;
String? _language;
// Page view removed; continuous-only
double? _exportDpi;
@override
void initState() {
@ -21,6 +22,7 @@ class _SettingsDialogState extends ConsumerState<SettingsDialog> {
final prefs = ref.read(preferencesProvider);
_theme = prefs.theme;
_language = prefs.language;
_exportDpi = prefs.exportDpi;
// pageView no longer configurable (continuous-only)
}
@ -118,6 +120,29 @@ class _SettingsDialogState extends ConsumerState<SettingsDialog> {
),
],
),
Row(
children: [
SizedBox(width: 140, child: Text('${l.dpi}:')),
const SizedBox(width: 8),
Expanded(
child: DropdownButton<double>(
key: const Key('ddl_export_dpi'),
isExpanded: true,
value: _exportDpi,
items:
const [96.0, 144.0, 200.0, 300.0]
.map(
(v) => DropdownMenuItem<double>(
value: v,
child: Text(v.toStringAsFixed(0)),
),
)
.toList(),
onChanged: (v) => setState(() => _exportDpi = v),
),
),
],
),
const SizedBox(height: 16),
Text(l.display, style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: 8),
@ -149,7 +174,7 @@ class _SettingsDialogState extends ConsumerState<SettingsDialog> {
),
],
),
// Page view setting removed (continuous-only)
const SizedBox(height: 24),
Row(
mainAxisAlignment: MainAxisAlignment.end,
@ -164,6 +189,7 @@ class _SettingsDialogState extends ConsumerState<SettingsDialog> {
final n = ref.read(preferencesProvider.notifier);
if (_theme != null) await n.setTheme(_theme!);
if (_language != null) await n.setLanguage(_language!);
if (_exportDpi != null) await n.setExportDpi(_exportDpi!);
// pageView not configurable anymore
if (mounted) Navigator.of(context).pop(true);
},