Mangayomi Documentation

repository·main·Indexed 25 days ago

https://github.com/kodjodevf/mangayomi

An open-source Flutter application for reading manga, webtoons, and novels, and watching anime and movies. The documentation covers development environment setup using flutter_rust_bridge, extension development in Dart and JavaScript, iOS sideloading and customization, local library scanning for various media types, TV mode configurations, and a Go-based torrent server API for streaming and managing torrents.

Tokens
6.4K
Snippets
10
Records
42
Agent score
86%

What's inside Mangayomi

  1. Sideload Mangayomi on iOS

    main

    For iOS users using sideloading tools, you can use the following sources to install Mangayomi. Note that only releases version 0.5.2 and higher are signed and compatible with AltStore and SideStore.

    • AltStore: altstore://source?url=https://raw.githubusercontent.com/kodjodevf/mangayomi/refs/heads/main/repo/source.json
    • Feather: feather://source/https://raw.githubusercontent.com/kodjodevf/mangayomi/refs/heads/main/repo/source.json
    • SideStore: sidestore://source?url=https://raw.githubusercontent.com/kodjodevf/mangayomi/refs/heads/main/repo/source.json
    • Direct URL: https://raw.githubusercontent.com/kodjodevf/mangayomi/refs/heads/main/repo/source.json
  2. Customize the iOS launch screen assets

    main

    To change the launch screen image for the iOS version of the application, you can use one of two methods:

    1. Direct File Replacement: Replace the existing image files located in the ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory with your own assets.
    2. Xcode Interface:
      • Open the iOS project in Xcode by running open ios/Runner.xcworkspace from your terminal.
      • In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
      • Drag and drop your desired images into the asset catalog to replace the launch screen assets.
    open ios/Runner.xcworkspace
  3. Set up development environment with flutter_rust_bridge

    main

    To build and run Mangayomi, you must have the Flutter SDK and the Rust toolchain installed.

    1. Verify your installation:
    rustc --version
    flutter doctor
    1. Install the flutter_rust_bridge_codegen CLI tool:
    cargo install 'flutter_rust_bridge_codegen'
    1. Generate the bridge code:
    flutter_rust_bridge_codegen generate
    1. Run the application:
    flutter run
    rustc --version
    flutter doctor
    cargo install 'flutter_rust_bridge_codegen'
    flutter_rust_bridge_codegen generate
    flutter run
  4. Use SubsamplingScaleImageView for high-resolution image rendering

    main

    SubsamplingScaleImageView is a Flutter widget designed for efficient rendering of very large images using a tiling engine. It supports various fitting modes, zoom limits, and panning constraints.

    Key Features

    • Tiling Engine: Renders only the visible parts of high-resolution images to save memory.
    • Scale Modes: Supports centerInside, centerCrop, fitWidth, fitHeight, originalSize, smartFit, and custom via ScaleType.
    • Pan Limits: Control how much the image can be panned using PanLimit (inside, outside, or center).
    • Custom Loading UI: Use the loadStateChanged callback to provide custom widgets for loading or error states.
    • Direct File Loading: Use resolvedFilePath to bypass the standard ImageProvider pipeline for faster loading from a known local path.

    Example Usage

    SubsamplingScaleImageView(
      image: NetworkImage('https://example.com/large_image.jpg'),
      minimumScaleType: ScaleType.fitWidth,
      panLimit: PanLimit.inside,
      loadStateChanged: (state) {
        if (state.loadState == LoadState.failed) {
          return GestureDetector(
            onTap: state.reLoadImage,
            child: const Icon(Icons.error),
          );
        }
        if (state.loadState == LoadState.loading) {
          final progress = state.loadingProgress?.expectedTotalBytes != null
              ? state.loadingProgress!.cumulativeBytesLoaded /
                  state.loadingProgress!.expectedTotalBytes!
              : 0.0;
          return CircularProgressIndicator(value: progress > 0 ? progress : null);
        }
        return null; // Use default display
      },
    )
  5. Integrate Cargo builds with Flutter plugins using Cargokit

    main

    Cargokit is an experimental tool used to seamlessly integrate Cargo (Rust) builds with Flutter plugins and packages. This allows for using Rust code within a Flutter plugin without requiring prebuilt binaries.

    For a detailed tutorial on how to implement this pattern, refer to the guide by Matej Kopnopp: https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/

    To see a concrete implementation, examine the hello_rust_ffi_plugin repository: https://github.com/irondash/hello_rust_ffi_plugin.

  6. Configure the Torrent Server

    main

    The Config struct defines the initial setup for the server:

    • Address: The TCP address to listen on (e.g., 127.0.0.1:8080). If not specified, it defaults to 127.0.0.1:0.
    • Path: The absolute directory path where torrent data will be stored.
    type Config struct {
    	Address string `json:"address"`
    	Path    string `json:"path"`
    }
  7. Configure SubsamplingScaleImageView widget

    main

    The SubsamplingScaleImageView is a high-resolution image viewer that supports tiling, zooming, and panning. When implementing this widget, you can configure several behaviors via its properties:

    • Interaction Control:

      • zoomEnabled: Enables/disables pinch-to-zoom.
      • panEnabled: Enables/disables panning.
      • quickScaleEnabled: Enables a specific scaling mode (often triggered by vertical movement).
      • doubleTapZoomScale: The scale factor used during a double-tap zoom (defaults to minScale * 2.5).
      • doubleTapZoomDuration: The duration of the double-tap zoom animation.
    • Callbacks:

      • onReady: Called when the image is fully loaded and ready.
      • onImageLoaded: Called with the original image dimensions (width, height) once loaded.
      • onTileError: Called with an error message if a specific image tile fails to decode.
      • onTileError: (Alternative) onTileError provides the error string.
      • loadStateChanged: A builder callback that allows you to return a custom widget based on the current LoadState (e.g., showing a custom loading spinner or error UI).
    • Visuals:

      • rotation: The rotation applied to the image.
      • cropBorders: Whether to apply crop borders during decoding.
      • showDebug: Enables debug rendering for tiles.
      • color / colorBlendMode: Controls how color is applied to the rendered image.
      • filterQuality: Sets the ui.FilterQuality for rendering.
  8. Manage a WorkerPool for concurrent tasks

    main

    The WorkerPool manages a pool of goroutines to handle concurrent I/O tasks.

    • NewWorkerPool(workers int) *WorkerPool: Creates a new pool. If workers <= 0, it defaults to the number of CPUs.
    • Submit(job func()) bool: Submits a job to the queue. Returns false if the pool is stopped or the job is nil.
    • Stop(): Gracefully stops the pool, closing the job queue and waiting for active workers to finish.