From 7493b964be3391858d79196a09c68d5a10953846 Mon Sep 17 00:00:00 2001 From: agrapine Date: Wed, 7 Aug 2019 19:05:39 +0100 Subject: [PATCH] added bend_box --- CHANGELOG.md | 5 ++--- README.md | 6 +++++- example/pubspec.lock | 2 +- lib/src/bend_box.dart | 40 ++++++++++++++++++++++++++++++++++++++++ lib/ux.dart | 5 ++++- pubspec.yaml | 43 ++----------------------------------------- 6 files changed, 54 insertions(+), 47 deletions(-) create mode 100644 lib/src/bend_box.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cc7d8..5e6a1cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,2 @@ -## 0.0.1 - -* TODO: Describe initial release. +### 0.0.2 +* Added BendBox diff --git a/README.md b/README.md index 8c58166..3e0ca20 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # ux -UX Kit \ No newline at end of file +UX Kit + +## Includes + +[x] BendBox \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index ca52990..806c1a5 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -141,7 +141,7 @@ packages: path: ".." relative: true source: path - version: "0.0.1" + version: "0.0.2" vector_math: dependency: transitive description: diff --git a/lib/src/bend_box.dart b/lib/src/bend_box.dart new file mode 100644 index 0000000..e51c448 --- /dev/null +++ b/lib/src/bend_box.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; + +class BendBox extends StatelessWidget { + final EdgeInsets inward; + final Color color; + + BendBox({this.inward = const EdgeInsets.all(0), this.color = Colors.red}); + + Widget build(BuildContext context) { + return CustomPaint(painter: _BendBoxPainter(inward: inward, color: color)); + } +} + +class _BendBoxPainter extends CustomPainter { + final EdgeInsets inward; + final Color color; + + _BendBoxPainter({this.inward, this.color}); + + void paint(Canvas canvas, Size size) { + final paint = Paint() + ..style = PaintingStyle.fill + ..isAntiAlias = true + ..color = color; + + final path = Path() + ..moveTo(0, 0) + ..quadraticBezierTo(size.width / 2, inward.top, size.width, 0) + ..quadraticBezierTo( + size.width - inward.left, size.height / 2, size.width, size.height) + ..quadraticBezierTo( + size.width / 2, size.height - inward.bottom, 0, size.height) + ..quadraticBezierTo(inward.left, size.height / 2, 0, 0) + ..close(); + + canvas.drawPath(path, paint); + } + + bool shouldRepaint(CustomPainter oldDelegate) => true; +} diff --git a/lib/ux.dart b/lib/ux.dart index ce3aca7..7e0a07f 100644 --- a/lib/ux.dart +++ b/lib/ux.dart @@ -1,7 +1,10 @@ -import 'dart:async'; +library scoped; +import 'dart:async'; import 'package:flutter/services.dart'; +export 'src/bend_box.dart'; + class Ux { static const MethodChannel _channel = const MethodChannel('ux'); diff --git a/pubspec.yaml b/pubspec.yaml index c879a71..8303ba8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: ux description: UX Kit -version: 0.0.1 +version: 0.0.2 author: Alexandru R. Agrapine homepage: https://swipelab.co/ @@ -15,46 +15,7 @@ dev_dependencies: flutter_test: sdk: flutter -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. flutter: - # This section identifies this Flutter project as a plugin project. - # The androidPackage and pluginClass identifiers should not ordinarily - # be modified. They are used by the tooling to maintain consistency when - # adding or updating assets for this project. plugin: androidPackage: io.swipelab.ux - pluginClass: UxPlugin - - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages + pluginClass: UxPlugin \ No newline at end of file