ripple_color_selection 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

ripple_color_selection #

A simple color selection widget with a charming ripple effect

Standard Widget

class FullPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    ColorSelectionController _controller = new ColorSelectionController();

    return Scaffold(
      body: Container(
        child: RippleColorSelection(
          controller: _controller,
        ),
      ),
    );
  }
}

You can also create your own custom tile:

Custom Tile

import 'package:flutter/material.dart';
import 'package:ripple_color_selection/controller/color_selection_controller.dart';
import 'package:ripple_color_selection/holder_classes/color_selection_border_animation_holder.dart';
import 'color_selection_tile.dart';


class RectangleTile extends ColorSelectionTile {

  // the path will define the shape of the tile
  @override
  Path get path =>
      new Path()
        ..addRect(Rect.fromCenter(width: size.width,
            height: size.height,
            center: Offset(size.width / 2, size.height / 2)));

  @override
  CustomClipper get customClipper =>
      Clipper(
          path: path
      );

  // the padding between each tile
  @override
  double get padding => 5.0;

  // the passed parameter are required. You should include them in your own tile
  RectangleTile({
    @required Color color,
    @required Function onTap,
    @required ColorSelectionBorderAnimationHolder borderAnimation,
    @required ColorSelectionValue colorSelectionValue,
    @required GlobalKey key,
    bool hasShadow = true
  }) : super(
      color: color,
      onTap: onTap,
      key: key,
      borderAnimation: borderAnimation,
      colorSelectionValue: colorSelectionValue,
      hasShadow: hasShadow
  );

}

And here how you pass the new tile to the actual widget

class CustomTilePage extends StatelessWidget {

  ColorSelectionController _controller = new ColorSelectionController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: RippleColorSelection.customTile(
            rippleExpandDuration: const Duration(milliseconds: 1500),
            controller: _controller,
            // here in this tilebuilder you have to provide the custom tile
            tileBuilder: (key, color, holder, value, onTap){
              return RectangleTile(
                color: color,
                onTap: onTap,
                borderAnimation: holder,
                colorSelectionValue: value,
                key: key,
              );
            }
        ),
      ),
    );
  }
}

You're even able to go fully crazy and define a custom ripple :o

Standard Widget

/// This page has a [CircleTile] as tapable widget
/// and a [RectangleTile] as the expanding widget, that
/// will grow underneath the clicked color
class FullyCustomPage extends StatelessWidget {

  ColorSelectionController _controller = new ColorSelectionController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: RippleColorSelection.custom(
            rippleExpandDuration: const Duration(seconds: 10),
            controller: _controller,
            tileBuilder: (key, color, holder, value, onTap){
              return RectangleTile(
                color: color,
                onTap: onTap,
                borderAnimation: holder,
                colorSelectionValue: value,
                key: key,
                hasShadow: false,
              );
            },
          rippleTileBuilder: (key, color, holder, value, onTap){
            return StarTile(
              color: color,
              onTap: onTap,
              borderAnimation: holder,
              colorSelectionValue: value,
              key: key,
            );
          },
        ),
      ),
    );
  }
}

TODO #

  • [ ] Make Widget working in Column without flexible
  • [ ] Make Widget not consume full height
  • [ ] Add some more tests
  • [ ] Make the Tilebuilder more simple
  • [ ] Make the Ripplebuilder more simple
  • [ ] Use a better method to draw border around tiles
  • [ ] Write some more examples

License #

MIT License

Copyright (c) 2019 Justin Vietz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[0.0.4] - 2019-09-07

  • Corrected formatting of checkboxes in readme
  • Corrected wrong resizing of gifs

[0.0.3] - 2019-09-06

  • Updated broken Link in README
  • Added TODOs in README
  • Added license to README
  • Added README to example
  • Added some showcase git to example
  • Resized gifs
  • formated all files with "flutter format"

[0.0.2] - 2019-09-06

  • Added a README file

[0.0.1] - 2019-09-06

  • This is the very first release of the color_selection_widget
  • It will provide basic functionality of displaying the widget
  • Select a color you like while watching a beautiful ripple animation

example/README.md

Example #

This is a simple example of the Usage of the ripple_color_selection Library. You can find the full code of this package and it's examples on github.

Selection With Listener

class ColorSelectionPageWithListener extends StatefulWidget {
  @override
  _ColorSelectionPageWithListenerState createState() => _ColorSelectionPageWithListenerState();

  @override
  String toString({DiagnosticLevel minLevel = DiagnosticLevel.debug}) {
    return "Page with listener";
  }
}

class _ColorSelectionPageWithListenerState extends State<ColorSelectionPageWithListener> {

  ColorSelectionController _colorSelectionController;

  @override
  void initState() {
    _colorSelectionController = new ColorSelectionController();
    _colorSelectionController.addListener(() {
      setState(() {

      });
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Sampletext"),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            Flexible(
              child: RippleColorSelection(
                controller: _colorSelectionController,
                colors: [
                  Colors.blue,
                  Colors.pink,
                  Colors.yellow,
                  Colors.green,
                  Colors.blue
                ],
              ),
            ),
            Text(_colorSelectionController.value.selectedColor.toString(), style: TextStyle(fontSize: 36.0, fontWeight: FontWeight.bold),),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  ripple_color_selection: ^0.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:ripple_color_selection/ripple_color_selection.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
28
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Oct 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test