Code Monkey home page Code Monkey logo

flutter_ahlib's Introduction

Introduction

Stars Earned Collaborated Stars Followers Repositories GitHub Page

  • ๐Ÿ‘‹ Hi! Here is AoiHosizora (้’ใ„ใปใ—ใžใ‚‰), majors in Intelligent Software and Robotics, Software Engineering.
  • ๐Ÿ“ Speaking languages: Mandarin Chinese (Native), Teo-Swa-uรช (Native), English (CET-6), Japanese (JLPT-N1).
  • ๐Ÿข Some owned GitHub organizations: ah-shellext & ah-forklib, my public email: [email protected].
  • ๐Ÿš€ Interest areas: distributed backend system development, desktop client and android client development.
  • โšก Favorite programming languages: Go, Dart, C#, Kotlin, Rust, Typescript, etc.

Coding status

flutter_ahlib's People

Contributors

aoi-hosizora avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

flutter_ahlib's Issues

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']);
      });

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,
      ),
    ),
  ),
),

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.

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

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,
      ),
    );
  }
}

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),

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.