forked from ElRojo7u7/cubixd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bb57801
Showing
28 changed files
with
2,184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build outputs. | ||
build/ | ||
|
||
# Omit committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.1.0 | ||
|
||
- Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 ElRojo | ||
|
||
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. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'dart:math'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:cubixd/cubixd.dart'; | ||
|
||
class Home extends StatefulWidget { | ||
Home({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<Home> createState() => _HomeState(); | ||
} | ||
|
||
class _HomeState extends State<Home> with TickerProviderStateMixin { | ||
late final AnimationController _ctrl; | ||
|
||
@override | ||
void initState() { | ||
_ctrl = | ||
AnimationController(vsync: this, duration: const Duration(seconds: 10)); | ||
_ctrl.forward(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar(title: Text("CubixD test")), | ||
body: Center( | ||
child: AnimatedCubixD( | ||
size: 300, | ||
// simplePosAnim: SimpleAnimRequirements( | ||
// duration: const Duration(seconds: 8), | ||
// xBegin: pi / 4, | ||
// xEnd: 2 * pi, | ||
// yBegin: -pi / 4, | ||
// yEnd: 4 * pi, | ||
// reverseWhenDone: true, | ||
// ), | ||
advancedXYposAnim: AnimRequirements( | ||
controller: _ctrl, | ||
xAnimation: Tween<double>(begin: -pi / 4, end: pi * 2 - pi / 4) | ||
.animate(_ctrl), | ||
yAnimation: | ||
Tween<double>(begin: pi / 4, end: pi / 4).animate(_ctrl), | ||
), | ||
stars: true, | ||
shadow: true, | ||
onSelected: (SelectedSide opt) { | ||
switch (opt) { | ||
case SelectedSide.back: | ||
return true; | ||
case SelectedSide.top: | ||
return true; | ||
case SelectedSide.front: | ||
return true; | ||
case SelectedSide.bottom: | ||
return false; // out of service | ||
case SelectedSide.right: | ||
return true; | ||
case SelectedSide.left: | ||
return true; | ||
case SelectedSide.none: | ||
return false; | ||
default: | ||
throw Exception("Unimplemented option"); | ||
} | ||
}, | ||
top: Container( | ||
color: Colors.red, | ||
), | ||
bottom: Container( | ||
color: Colors.pink, | ||
), | ||
left: Container( | ||
color: Colors.blue, | ||
), | ||
right: Container( | ||
color: Colors.yellow, | ||
), | ||
front: Container( | ||
color: Colors.amber, | ||
), | ||
back: Container( | ||
color: Colors.greenAccent, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// Create a 3d cube!! | ||
library cubixd; | ||
|
||
export 'src/widgets/index.dart' show AnimatedCubixD, CubixD; | ||
export 'src/models/index.dart' show AnimRequirements, SimpleAnimRequirements; | ||
export 'src/enums/index.dart' show SelectedSide; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
enum CurrentState { moving, selected, restore } | ||
|
||
enum SelectedSide { front, back, right, left, top, bottom, none } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'package:cubixd/src/enums/cubixdEnums.emum.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'dart:async' show Timer; | ||
|
||
import 'package:flutter/material.dart' show VoidCallback; | ||
|
||
class CubixdDebouncer { | ||
final Duration debounceTime; | ||
Timer? _timer; | ||
|
||
CubixdDebouncer({required this.debounceTime}); | ||
|
||
run(VoidCallback action) { | ||
_timer?.cancel(); | ||
_timer = Timer(debounceTime, action); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'package:cubixd/src/helpers/debouncer.helper.dart'; | ||
export 'package:cubixd/src/helpers/triggerSwitch.helper.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter/material.dart' show VoidCallback; | ||
|
||
class CubixdTriggerSwitch { | ||
bool _opt; | ||
CubixdTriggerSwitch(this._opt); | ||
|
||
void run(VoidCallback call, bool opt) { | ||
if (_opt != opt) { | ||
call(); | ||
_opt = !_opt; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter/animation.dart' show Animation, AnimationController; | ||
|
||
class AnimRequirements { | ||
final AnimationController controller; | ||
final Animation<double> xAnimation; | ||
final Animation<double> yAnimation; | ||
|
||
AnimRequirements({ | ||
required this.controller, | ||
required this.xAnimation, | ||
required this.yAnimation, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'package:cubixd/src/models/animRequirements.model.dart'; | ||
export 'package:cubixd/src/models/simpleAnimRequirements.model.dart'; | ||
export 'package:cubixd/src/models/starsAnimations.model.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:flutter/animation.dart' show Curve, Curves; | ||
|
||
class SimpleAnimRequirements { | ||
/// The angle in radians that whould be set when the animation starts | ||
final double xBegin; | ||
|
||
/// The angle in radians that should be set when the animation ends | ||
final double xEnd; | ||
|
||
/// The angle in radians that whould be set when the animation starts | ||
final double yBegin; | ||
|
||
/// The angle in radians that should be set when the animation ends | ||
final double yEnd; | ||
|
||
/// If the animation repeats infinitely | ||
/// | ||
/// By default: `infinite: true` | ||
final bool infinite; | ||
|
||
/// If the animation shoud play backwards when it finishes | ||
/// | ||
/// By default: `reverseWhenDone: false` | ||
final bool reverseWhenDone; | ||
|
||
/// Duration of the cubixd rotation | ||
final Duration duration; | ||
|
||
/// Curve that should be excecuted by playing the animation | ||
/// on the x angle (horizontal) | ||
/// | ||
/// By default: `xCurve = Curves.liner` | ||
final Curve xCurve; | ||
|
||
/// Curve that should be excecuted by playing the animation | ||
/// on the y angle (vertical) | ||
/// | ||
/// By default: `yCurve = Curves.liner` | ||
final Curve yCurve; | ||
|
||
SimpleAnimRequirements({ | ||
required this.duration, | ||
required this.xBegin, | ||
required this.xEnd, | ||
required this.yBegin, | ||
required this.yEnd, | ||
this.infinite = true, | ||
this.reverseWhenDone = false, | ||
this.xCurve = Curves.linear, | ||
this.yCurve = Curves.linear, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:flutter/animation.dart' show Animation; | ||
|
||
class StarsAnimations { | ||
final Animation<double> xAnim; | ||
final Animation<double> yAnim; | ||
final double size; | ||
|
||
StarsAnimations(this.xAnim, this.yAnim, this.size); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'dart:math' as math; | ||
|
||
import 'package:flutter/material.dart' show Widget, AnimationController; | ||
import 'package:vector_math/vector_math_64.dart' show Vector2; | ||
|
||
import '../enums/index.dart' show SelectedSide; | ||
|
||
typedef OnSelectedC = void Function(SelectedSide opt, Vector2 delta); | ||
typedef OnSelectedA = bool Function(SelectedSide opt); | ||
typedef BuildOnSelect = Widget Function( | ||
double size, AnimationController selecCtrl); | ||
|
||
abstract class CubixdUtils { | ||
// The margin factor to consider the selection (iSel * fiveDeg) | ||
static const int iSel = 4; | ||
static const double fiveDeg = math.pi / 36; | ||
|
||
static double getIvalue(double val) { | ||
final resP = val.abs() % (math.pi / 2); | ||
final resN = -val.abs() % (math.pi / 2); | ||
if (resP < CubixdUtils.iSel * CubixdUtils.fiveDeg) { | ||
return val < 0 ? val + resP : val - resP; | ||
} | ||
return val < 0 ? val - resN : val + resN; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'package:cubixd/src/types/cubixdTypes.type.dart'; |
Oops, something went wrong.