GithubHelp home page GithubHelp logo

aoi-hosizora / flutter_ahlib Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 938 KB

A personal flutter library, contains some useful widgets and utils.

License: MIT License

Dart 99.54% Kotlin 0.01% Swift 0.04% Objective-C 0.01% HTML 0.40%

flutter_ahlib's Introduction

flutter_ahlib

Build Status Release pub package License

  • A personal flutter library, contains some useful widgets and utilities.
  • Please visit https://pub.dev/packages/flutter_ahlib for details. Note that this library only passes tests in Flutter 2.x.

Usage

// Import the whole library, including common widgets, list widgets, image widgets and utilities.
import 'package:flutter_ahlib/flutter_ahlib.dart';

// Only import the util library.
import 'package:flutter_ahlib/flutter_ahlib_util.dart'; 

Library contents

  • Common widgets (lib/src/widget/)
    • AnimatedFab ScrollAnimatedFab AnimatedFabController
    • AppBarActionButtonTheme AppBarActionButton
    • CustomDrawerController CustomDrawerControllerState
    • CustomInkRipple CustomInkSplash
    • CustomInkWell CustomInkResponse
    • CustomPageRoute CustomPageRouteTheme NoPopGestureCupertinoPageTransitionsBuilder
    • CustomScrollPhysics CustomScrollPhysicsController DefaultCustomScrollPhysics
    • CustomSingleChildLayoutDelegate
    • DrawerScaffold DrawerScaffoldState
    • ExtendedDropdownButton ExtendedDropdownButtonState ViewInsetsData
    • ExtendedNestedScrollView ExtendedNestedScrollViewState
    • ExtendedScrollbar
    • ExtendedTabBarView ExtendedTabBarViewState
    • IconText
    • LazyIndexedStack PositionArgument
    • NestedPageViewNotifier
    • flatButtonStyle raisedButtonStyle outlineButtonStyle ThemeDataExtension
    • OverflowClipBox
    • PlaceholderText PreviouslySwitchedWidget switchLayoutBuilderWithSwitchedFlag
    • TextDialogOption IconTextDialogOption CircularProgressDialogOption showYesNoAlertDialog
    • PreloadablePageView PageChangedListener
    • SliverHeaderDelegate SliverSeparatedListDelegate SliverSeparatedListBuilderDelegate
    • TableWholeRowInkWell TableCellHelper
    • TextGroup
    • TextSelectionConfig TextSelectionWithColorHandle
    • VideoProgressIndicator
    • StatelessWidgetWithCallback StatefulWidgetWithCallback
  • List widgets (lib/src/list/)
    • AppendIndicator AppendIndicatorState
    • MultiSelectable MultiSelectableController SelectableItem SelectableCheckboxItem
    • RefreshableDataView RefreshableDataViewState
    • PaginationDataView PaginationDataViewState
    • UpdatableDataView
  • Image widgets (lib/src/image/)
    • ExtendedPhotoGallery ExtendedPhotoGalleryState
    • loadLocalOrNetworkImageBytes loadLocalOrNetworkImageCodec
    • LocalOrCachedNetworkImage
    • LocalOrCachedNetworkImageProvider
    • MultiImageStreamCompleter
    • ReloadablePhotoView ReloadablePhotoViewState
  • Utilities (lib/src/util/)
    • ActionController
    • BoolExtension IterableExtension ListExtension ObjectExtension FutureExtension
    • downloadFile
    • ExtendedLogger PreferredPrinter
    • filesize filesizeWithoutSpace
    • Flutter material constants
    • StateExtension ScrollControllerExtension ScrollMetricsExtension PageControllerExtension ColorExtension TextSpanExtension RenderObjectExtension BuildContextExtension
    • getMimeFromExtension getExtensionsFromMime getPreferredExtensionFromMime
    • TaskResult Ok Err TaskResultFutureExtension
    • Tuple2 ~ Tuple6

Dependencies

environment:
  sdk: ">=2.16.2 <3.0.0"

dependencies:
  flutter_cache_manager: ^3.3.0
  flutter_staggered_grid_view: ^0.6.2
  http: ^0.13.5
  logger: ^1.2.2
  octo_image: ^1.0.2
  path: ^1.8.0
  photo_view: ^0.14.0

dev_dependencies:
  flutter_lints: ^1.0.0

flutter_ahlib's People

Contributors

aoi-hosizora avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

flutter_ahlib's Issues

AppendIndicator done_before record

enum _AppendIndicatorMode {
  drag, // start to show
  armed, // drag far enough
  append, // run the append callback
  done_before, // before append callback is done
  done, // append callback is done
  canceled, // canceled by no arming
}
  static const _kScaleSlowDuration = Duration(milliseconds: 400);
  static const _kScaleFastDuration = Duration(milliseconds: 100);
  static const _kProgressFadeDuration = Duration(milliseconds: 100);
  static const _kProgressIncrDuration = Duration(milliseconds: 150);
  static const _kProgressFinalDuration = Duration(milliseconds: 150);
  AnimationController _progressController;
  Animation<double> _progressAnimation;

  void initState() {
    super.initState();
    _sizeController = AnimationController(vsync: this);
    _sizeFactor = _sizeController.drive(Tween(begin: 0.0, end: 1.0));
    _progressController = AnimationController(vsync: this);
    _progressAnimation = _progressController.drive(Tween(begin: 0.0, end: 1.0));
  }

  void _start() {
    _sizeController.value = 0.0;
    _progressController.value = 0.0;
    _dragOffset = 0;
  }
  /// Show animation with "-> fade -> increasing -> shrink" or "-> shrink".
  void _dismiss(_AppendIndicatorMode newMode) async {
    if (newMode == _AppendIndicatorMode.canceled) {
      // -> cancel
      _mode = _AppendIndicatorMode.canceled;
      if (mounted) setState(() {});
    } else if (newMode == _AppendIndicatorMode.done) {
      // -> done_before
      _mode = _AppendIndicatorMode.done_before;
      if (mounted) setState(() {});
      await Future.delayed(_kProgressFadeDuration); // fade
      await _progressController.animateTo(1.0, duration: _kProgressIncrDuration); // increasing
      await Future.delayed(_kProgressFinalDuration);
      // -> done
      _mode = _AppendIndicatorMode.done;
      if (mounted) setState(() {});
    }
    await _sizeController.animateTo(0.0, duration: _kScaleSlowDuration, curve: Curves.easeOutCubic); // shrink

    // -> null
    _mode = null;
    if (mounted) setState(() {});
  }
SizeTransition(
  sizeFactor: _sizeFactor,
  axis: Axis.horizontal,
  child: AnimatedCrossFade(
    duration: _kProgressFadeDuration,
    crossFadeState: _mode == _AppendIndicatorMode.done_before || _mode == _AppendIndicatorMode.done ? CrossFadeState.showSecond : CrossFadeState.showFirst,
    firstChild: LinearProgressIndicator(
      value: _mode == _AppendIndicatorMode.append || _mode == _AppendIndicatorMode.done_before || _mode == _AppendIndicatorMode.done ? null : 0,
      minHeight: widget.minHeight,
      backgroundColor: widget.backgroundColor,
      valueColor: widget.valueColor,
    ),
    secondChild: AnimatedBuilder(
      animation: _progressAnimation,
      builder: (_, __) => LinearProgressIndicator(
        value: _progressAnimation.value,
        minHeight: widget.minHeight,
        backgroundColor: widget.backgroundColor,
        valueColor: widget.valueColor,
      ),
    ),
  ),
),

Adjust TextGroup and SliverAppBarDelegate

Here should be add(xxx) rather than insert(0, xxx).

children: spans..insert(0, TextSpan(text: ' ')), // insert an empty TextSpan.

Add these options (or others) for TextGroup.

// showCursor: widget.showCursor,
// autofocus: widget.autofocus,

Here should use assert rather than math.max:

}) : assert(minHeight != null),
assert(maxHeight != null),

Add header for http.head in LocalOrNetworkImageProvider

The http.head header should contain the headers parameter.

      int totalSize;
      http.head(url, headers: {
        'Accept': '*/*',
        'Accept-Encoding': '',
      }).then((data) {
        totalSize = int.tryParse(data.headers['content-length']);
      });

Update controller extensions

Use optional parameters to scrollXXX methods.

void scrollWithAnimate(double offset, {Curve curve = Curves.easeOutCirc, Duration duration = const Duration(milliseconds: 500)}) {
animateTo(offset, curve: curve, duration: duration);
}

Add PageController extension and add scrollWithAnimate method.

PageController _controller;
_controller.animateToPage(index, duration: kTabScrollDuration, curve: Curves.easeOutQuad);

Rename some method names.

bool containAction(dynamic key) {
return _actions.containsKey(key);
}

Use default value AlwaysScrollableScrollPhysics() for physics.

BannedIcon record

/// An [Icon] with a line from left top to bottom right, which is rendered by [CustomPaint].
class BannedIcon extends StatelessWidget {
  const BannedIcon({
    Key key,
    @required this.icon,
    this.banned = true,
    @required this.color,
    @required this.backgroundColor,
    this.offset = 3.0,
    this.lineWidth = 3.0,
    this.blinkLineWidth = 2.0,
    this.size = Size.zero,
  })  : assert(icon != null),
        assert(banned != null),
        assert(offset != null),
        assert(color != null),
        assert(backgroundColor != null),
        assert(lineWidth != null),
        assert(blinkLineWidth != null),
        assert(size != null),
        super(key: key);

  /// Content icon, the shape of line depends on this widget's size.
  final Widget icon;

  /// Paint the line or not.
  final bool banned;

  /// Color of line, need to be the same as icon's color.
  final Color color;

  /// Color of background, used to paint the blink line.
  final Color backgroundColor;

  /// Line position offset from the icon size, default is 3.0.
  final double offset;

  /// Line width, default is 3.0.
  final double lineWidth;

  /// Blink link width, default is 2.0, recommend to set a value that close to [lineWidth].
  final double blinkLineWidth;

  /// Icon size, default is [Size.zero] which depends on the child or parent.
  final Size size;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: CustomPaint(
        foregroundPainter: !banned
            ? null
            : FunctionPainter(
                onPaint: (canvas, size) {
                  // line
                  canvas.drawLine(
                    Offset(offset, offset),
                    Offset(size.width - offset, size.height - offset),
                    Paint()
                      ..color = color
                      ..strokeWidth = lineWidth,
                  );
                  // blink line
                  canvas.drawLine(
                    Offset(offset, offset - blinkLineWidth),
                    Offset(size.width - offset + blinkLineWidth, size.height - offset),
                    Paint()
                      ..color = backgroundColor
                      ..strokeWidth = blinkLineWidth,
                  );
                },
              ),
        child: icon,
        size: size,
        willChange: banned ? true : false,
      ),
    );
  }
}

Refactor and release to v1.2

Refactor the whole library, rewrite the comments, release to v1.2.

Widget progress: (9)

  • placeholder_text.dart
  • drawer_list_view.dart
  • icon_text.dart
  • popup_menu.dart -> popup_list_menu.dart
  • ripple_sized_view.dart
  • scroll_fab.dart -> animated_fab.dart
  • scroll_fab_controller.dart
  • sliver_appbar_delegate.dart -> sliver_daelegate.dart
  • sliver_container.dart
  • dummy_view.dart
  • text_group.dart
  • lazy_indexed_stack.dart
  • tab_in_page_notification.dart
  • function_drawer.dart

List related progress: (4)

  • append_indicator.dart
  • refresh_listview.dart
  • refresh_sliver_listview.dart
  • refresh_staggered_grivview.dart
  • append_listview.dart
  • append_sliver_listview.dart
  • append_staggered_grivview.dart
  • scroll_more_controller.dart
  • updatable_dataview.dart
  • refreshable_dataview.dart
  • pagination_dataview.dart

Image related progress: (3)

  • local_network_image_provider.dart -> file_or_network_image_provider.dart
  • local_network_image_provider_io.dart -> file_or_network_image_provider_io.dart
  • multi_image_stream_completer.dart

Util related progress: (7)

  • action_controller.dart
  • tuple.dart
  • hash.dart
  • extensions.dart
  • dart_extension.dart
  • flutter_extension.dart
  • filesize.dart
  • notifier_data.dart

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.