mirror of
https://github.com/chenasraf/wheel_spinner.git
synced 2026-05-17 17:48:00 +00:00
initial commit
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
.DS_Store
|
||||
.dart_tool/
|
||||
|
||||
.packages
|
||||
.pub/
|
||||
|
||||
build/
|
||||
ios/.generated/
|
||||
ios/Flutter/Generated.xcconfig
|
||||
ios/Runner/GeneratedPluginRegistrant.*
|
||||
19
.idea/libraries/Dart_SDK.xml
generated
Normal file
19
.idea/libraries/Dart_SDK.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Dart SDK">
|
||||
<CLASSES>
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/async" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/collection" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/convert" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/core" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/developer" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/html" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/io" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/isolate" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/math" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/mirrors" />
|
||||
<root url="file:///Users/chenasraf/.flutter.src/bin/cache/dart-sdk/lib/typed_data" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/wheel_spinner.iml" filepath="$PROJECT_DIR$/wheel_spinner.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
36
.idea/workspace.xml
generated
Normal file
36
.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="main.dart" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/lib/main.dart">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane">
|
||||
<option name="show-excluded-files" value="false" />
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="dart.analysis.tool.window.force.activate" value="true" />
|
||||
<property name="show.migrate.to.gradle.popup" value="false" />
|
||||
</component>
|
||||
</project>
|
||||
10
.metadata
Normal file
10
.metadata
Normal file
@@ -0,0 +1,10 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: e5b1ed7a7f7b85c1877e09a9495681f719be5578
|
||||
channel: dev
|
||||
|
||||
project_type: package
|
||||
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## [0.0.1] - 10 Mar, 2019
|
||||
|
||||
* Initial release
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) [year] [fullname]
|
||||
|
||||
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.
|
||||
8
README.md
Normal file
8
README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# wheel_spinner
|
||||
|
||||
WheelSpinner provides you with a simple number spinner that resembles a wheel, knob, or more specifically
|
||||
pitch bender knobs. It allows you to update a single `double` value.
|
||||
|
||||
## Getting Started
|
||||
|
||||
- TODO
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.flutter.plugins;
|
||||
|
||||
import io.flutter.plugin.common.PluginRegistry;
|
||||
|
||||
/**
|
||||
* Generated file. Do not edit.
|
||||
*/
|
||||
public final class GeneratedPluginRegistrant {
|
||||
public static void registerWith(PluginRegistry registry) {
|
||||
if (alreadyRegisteredWith(registry)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
|
||||
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
|
||||
if (registry.hasPlugin(key)) {
|
||||
return true;
|
||||
}
|
||||
registry.registrarFor(key);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
2
android/local.properties
Normal file
2
android/local.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
sdk.dir=/usr/local/Cellar/android-sdk/24.4.1_1
|
||||
flutter.sdk=/Users/chenasraf/.flutter.src
|
||||
4
lib/utils.dart
Normal file
4
lib/utils.dart
Normal file
@@ -0,0 +1,4 @@
|
||||
import 'dart:math';
|
||||
|
||||
double clamp<T extends num>(T number, T low, T high) =>
|
||||
max(low * 1.0, min(number * 1.0, high * 1.0));
|
||||
173
lib/wheel_spinner.dart
Normal file
173
lib/wheel_spinner.dart
Normal file
@@ -0,0 +1,173 @@
|
||||
library wheel_spinner;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wheel_spinner/utils.dart';
|
||||
|
||||
/// Shows a "dial" spinner that can be dragged up or down, either unlimited or
|
||||
/// restricted by [max] and [min].
|
||||
class WheelSpinner extends StatefulWidget {
|
||||
/// Callback for when the user drags the slider
|
||||
final Function(double value) onSlideUpdate;
|
||||
/// Callback for when the user lets go of the slider
|
||||
final Function(double value) onSlideDone;
|
||||
/// The widget width
|
||||
final double width;
|
||||
/// The widget height
|
||||
final double height;
|
||||
/// The initial value for the slider
|
||||
final double value;
|
||||
/// Minimum value to allow sliding to. Also appears on the bottom left of the slider
|
||||
final double min;
|
||||
/// Minimum value to allow sliding to. Also appears on the top left of the slider
|
||||
final double max;
|
||||
/// Allows adding a widget above the slider
|
||||
final Widget Function(double value) labelBuilder;
|
||||
|
||||
const WheelSpinner({
|
||||
Key key,
|
||||
this.onSlideUpdate,
|
||||
this.onSlideDone,
|
||||
this.width = 60,
|
||||
this.height = 100,
|
||||
this.min = double.negativeInfinity,
|
||||
this.max = double.infinity,
|
||||
this.value = 0.5,
|
||||
this.labelBuilder,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_WheelSpinnerState createState() => _WheelSpinnerState(value: value);
|
||||
}
|
||||
|
||||
class _WheelSpinnerState extends State<WheelSpinner> {
|
||||
double value;
|
||||
double dragValue;
|
||||
Offset dragOffset;
|
||||
|
||||
_WheelSpinnerState({this.value});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double shadowOffset = 0.2;
|
||||
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 4.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
widget.max.round().toString(),
|
||||
textScaleFactor: 0.75,
|
||||
),
|
||||
Text(
|
||||
widget.min.round().toString(),
|
||||
textScaleFactor: 0.75,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onVerticalDragStart: (details) {
|
||||
setState(() {
|
||||
dragOffset = details.globalPosition;
|
||||
dragValue = value;
|
||||
});
|
||||
},
|
||||
onVerticalDragUpdate: (details) {
|
||||
var newValue = clamp(
|
||||
dragValue - (details.globalPosition - dragOffset).dy / 20.0,
|
||||
widget.min,
|
||||
widget.max);
|
||||
setState(() {
|
||||
value = newValue;
|
||||
});
|
||||
if (widget.onSlideUpdate != null) {
|
||||
widget.onSlideUpdate(value);
|
||||
}
|
||||
},
|
||||
onVerticalDragEnd: (details) {
|
||||
setState(() {
|
||||
dragOffset = null;
|
||||
});
|
||||
if (widget.onSlideDone != null) {
|
||||
widget.onSlideDone(value);
|
||||
}
|
||||
},
|
||||
child: SizedBox.fromSize(
|
||||
size: Size(widget.width.toDouble(), widget.height.toDouble()),
|
||||
child: Container(
|
||||
child: Stack(
|
||||
children: List<Widget>.generate(
|
||||
20,
|
||||
(i) {
|
||||
double valueFraction = (value.ceil() - value) * 10;
|
||||
double top =
|
||||
(widget.height / 10 * i) - widget.height / 2;
|
||||
top += valueFraction;
|
||||
return Positioned.fromRect(
|
||||
rect: Rect.fromLTWH(
|
||||
0.0,
|
||||
top,
|
||||
widget.width.toDouble(),
|
||||
0,
|
||||
),
|
||||
child: Divider(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList() +
|
||||
(widget.labelBuilder != null
|
||||
? [widget.labelBuilder(value)]
|
||||
: []),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
stops: [0.0, shadowOffset, 1.0 - shadowOffset, 1.0],
|
||||
colors: [
|
||||
Colors.grey[350],
|
||||
Colors.grey[50],
|
||||
Colors.grey[50],
|
||||
Colors.grey[350]
|
||||
],
|
||||
),
|
||||
border: Border.all(
|
||||
width: 1,
|
||||
style: BorderStyle.solid,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(3.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 4.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'+',
|
||||
textScaleFactor: 0.75,
|
||||
),
|
||||
Text(
|
||||
'-',
|
||||
textScaleFactor: 0.75,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
139
pubspec.lock
Normal file
139
pubspec.lock
Normal file
@@ -0,0 +1,139 @@
|
||||
# Generated by pub
|
||||
# See https://www.dartlang.org/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.11"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.3+1"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.2"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.5"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.8"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
sdks:
|
||||
dart: ">=2.1.1-dev.0.0 <3.0.0"
|
||||
53
pubspec.yaml
Normal file
53
pubspec.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
name: wheel_spinner
|
||||
description: A simple Flutter widget for updating a number using a pitch bender-like spinner
|
||||
version: 0.0.1
|
||||
author: Chen Asraf <chen@asraf.me>
|
||||
homepage: https://github.com/chenasraf/wheel_spinner
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
||||
# To add assets to your 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.io/assets-and-images/#from-packages
|
||||
#
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.io/assets-and-images/#resolution-aware.
|
||||
|
||||
# To add custom fonts to your 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.io/custom-fonts/#from-packages
|
||||
19
wheel_spinner.iml
Normal file
19
wheel_spinner.iml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart Packages" level="project" />
|
||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||
<orderEntry type="library" name="Flutter Plugins" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
Reference in New Issue
Block a user