-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
13 changed files
with
223 additions
and
53 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 |
---|---|---|
|
@@ -72,3 +72,4 @@ build/ | |
!**/ios/**/default.mode2v3 | ||
!**/ios/**/default.pbxuser | ||
!**/ios/**/default.perspectivev3 | ||
.vscode/ |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
## [0.0.2] - 2020-11-25 | ||
|
||
* **NEW** now sections have customizable dividers to show its limits. | ||
* **NEW** you can adjust the offset angle of the sections with a `FixedAngle`. | ||
* Updated `example/example.dart`. | ||
* Updated sample images. | ||
|
||
## [0.0.1] - 2020-11-24 | ||
|
||
* First reviewed functional release | ||
* First reviewed functional release. |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,35 @@ | ||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:math'; | ||
|
||
/// FixedAngles enum that includes common angles for the ControlButton. | ||
enum FixedAngles { | ||
Zero, | ||
Rectangular90, | ||
Inclined45, | ||
Inclined120, | ||
Plane180, | ||
} | ||
|
||
/// Angles class provides helpers to convert FixedAngles to degrees or radians. | ||
class Angles { | ||
final Map<num, double> _angleMap = const { | ||
0: 0.0, | ||
1: 1.5708, | ||
2: 0.785398, | ||
3: 2.0944, | ||
4: 3.14159, | ||
}; | ||
|
||
/// fixedToRadian converts an object of class FixedAngles to radians | ||
double fixedToRadian(FixedAngles angle) { | ||
return _angleMap[angle.index]; | ||
} | ||
|
||
/// fixedToDegrees converts an object of class FixedAngles to degrees | ||
double fixedToDegrees(FixedAngles angle) { | ||
return _angleMap[angle.index] * 180 / pi; | ||
} | ||
} |
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
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
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,68 @@ | ||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import 'angles.dart'; | ||
|
||
/// PainterClass class that extends from CustomPainter provides the divisions for the ControlButton. | ||
class PainterClass extends CustomPainter { | ||
final int sections; | ||
final FixedAngles angle; | ||
final Color dividerColor; | ||
final double dividerThickness; | ||
|
||
/// PainterClass constructor. | ||
/// You can modify the sections in the ControlButton instance, this will follow along. | ||
PainterClass({ | ||
this.sections = 2, | ||
this.dividerThickness = 1.0, | ||
this.angle = FixedAngles.Zero, | ||
this.dividerColor = const Color(0x3377E7E7E), | ||
}); | ||
|
||
/// Override method on paint to draw in the canvas. | ||
@override | ||
void paint(Canvas canvas, Size size) { | ||
final pinkPaint = Paint() | ||
..style = PaintingStyle.stroke | ||
..strokeWidth = dividerThickness | ||
..color = dividerColor; | ||
|
||
_drawSections( | ||
canvas, | ||
sections, | ||
size, | ||
pinkPaint, | ||
Angles().fixedToRadian(angle), | ||
); | ||
} | ||
|
||
@override | ||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false; | ||
|
||
/// This functions draws the dividers only horizontally and rotates a defined angle while doing it. | ||
void _drawSections( | ||
Canvas canvas, int sections, Size size, Paint paint, double angleOffset) { | ||
double angle = 6.28319 / sections; | ||
|
||
canvas.save(); | ||
|
||
if (angleOffset != 0.0) { | ||
canvas.translate(size.width / 2, size.height / 2); | ||
canvas.rotate(0.785398); | ||
canvas.translate(-size.width / 2, -size.height / 2); | ||
} | ||
|
||
for (int i = 0; i < sections; i++) { | ||
canvas.translate(size.width / 2, size.height / 2); | ||
canvas.rotate(angle); | ||
canvas.translate(-size.width / 2, -size.height / 2); | ||
canvas.drawLine( | ||
Offset(0, size.width / 2), Offset(size.width, size.width / 2), paint); | ||
} | ||
|
||
canvas.restore(); | ||
} | ||
} |
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