Giter Site home page Giter Site logo

junko2013 / interactiveviewer_gallery Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qq326646683/interactiveviewer_gallery

0.0 0.0 0.0 118 KB

Enhancements to interactiveviewer: picture and video preview, support two-finger gesture zoom, double-click to zoom, switch left and right。图片预览,视频预览,图片视频混合预览

License: MIT License

Ruby 4.62% Objective-C 0.13% Kotlin 0.48% Dart 93.39% Swift 1.38%

interactiveviewer_gallery's Introduction

interactiveviewer_gallery

pub package

中文文档

A flutter library to show picture and video preview gallery support

  1. two-finger gesture zoom
  2. double-click to zoom
  3. switch left and right
  4. gesture back: scale, transfer, opacity of background
  5. video auto paused when miss focus

Preview

video for youtube

video for qiniu

apk download

Setup

because the library is base on InteractiveViewer so require flutter verion above or equal 1.20.0

interactiveviewer_gallery: ${last_version}

How to use

  1. Wrap Hero in your image gridview item:
Hero(
    tag: source.url,
    child: ${gridview item}
)
  1. gridview item's GestureDetector add jumping to interactiveviewer_gallery:
// DemoSourceEntity is your data model
// itemBuilder is gallery page item
void _openGallery(DemoSourceEntity source) {
  Navigator.of(context).push(
    HeroDialogRoute<void>(
      // DisplayGesture is just debug, please remove it when use
      builder: (BuildContext context) => InteractiveviewerGallery<DemoSourceEntity>(
          sources: sourceList,
          initIndex: sourceList.indexOf(source),
          itemBuilder: itemBuilder,
          onPageChanged: (int pageIndex) {
            print("nell-pageIndex:$pageIndex");
          },
      ),
    ),
  );
}
  1. edit itemBuilder: you can reference the example/lib/main.dart then customize
Widget itemBuilder(BuildContext context, int index, bool isFocus) {
  DemoSourceEntity sourceEntity = sourceList[index];
  if (sourceEntity.type == 'video') {
    return DemoVideoItem(
      sourceEntity,
      isFocus: isFocus,
    );
  } else {
    return DemoImageItem(sourceEntity);
  }
}

Other

Comments and pr are welcome

interactiveviewer_gallery's People

Contributors

junko2013 avatar qq326646683 avatar jerazo7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.