added bend_box

This commit is contained in:
agrapine
2019-08-07 19:05:39 +01:00
parent 810d060d44
commit 7493b964be
6 changed files with 54 additions and 47 deletions

View File

@@ -1,3 +1,2 @@
## 0.0.1
* TODO: Describe initial release.
### 0.0.2
* Added BendBox

View File

@@ -1,3 +1,7 @@
# ux
UX Kit
UX Kit
## Includes
[x] BendBox

View File

@@ -141,7 +141,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.0.2"
vector_math:
dependency: transitive
description:

40
lib/src/bend_box.dart Normal file
View File

@@ -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;
}

View File

@@ -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');

View File

@@ -1,6 +1,6 @@
name: ux
description: UX Kit
version: 0.0.1
version: 0.0.2
author: Alexandru R. Agrapine <alex@swipelab.co>
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