Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

сhevron_refactoring #44

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/components/buttons/rounded_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _RoundedButtonState extends State<RoundedButton> {

static const _additionalSpace = 1.0;

static const _defaultChevronOffset = Offset(4, 2);
static const _defaultChevronOffset = Offset(3.0, 9);

@override
Widget build(BuildContext context) {
Expand Down
45 changes: 25 additions & 20 deletions lib/src/components/chevron.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,15 @@ class Chevron extends StatelessWidget {

@override
Widget build(BuildContext context) {
return RotatedBox(
quarterTurns: _quartedTurnsForDirection(direction),
child: CustomPaint(
size: size,
painter: _CrossPainter(
color: color,
lineWidth: lineWidth,
),
return CustomPaint(
size: size,
painter: _ChevronPainter(
color: color,
lineWidth: lineWidth,
direction: direction,
),
);
}

int _quartedTurnsForDirection(ChevronDirection direction) {
return const {
ChevronDirection.down: 0,
ChevronDirection.left: 1,
ChevronDirection.up: 2,
ChevronDirection.right: 3,
}[direction] ??
0;
}
}

/// The direction where the chevron arrow will be pointing.
Expand All @@ -63,16 +51,31 @@ enum ChevronDirection {
left
}

class _CrossPainter extends CustomPainter {
class _ChevronPainter extends CustomPainter {
final double lineWidth;
final Color color;
final ChevronDirection direction;

/// constructor
_CrossPainter({
_ChevronPainter({
required this.color,
required this.lineWidth,
required this.direction,
});

double _getRadiansForDirection(ChevronDirection direction) {
const double _pi = 3.1415;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const double _halfOfPi = _pi / 2;

return {
ChevronDirection.down: 0.0,
ChevronDirection.left: _halfOfPi,
ChevronDirection.up: _pi,
ChevronDirection.right: -_halfOfPi,
}[direction] ??
0.0;
}

@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
Expand All @@ -87,6 +90,8 @@ class _CrossPainter extends CustomPainter {

final x = halfLine / 2;

canvas.rotate(_getRadiansForDirection(direction));

canvas.drawLine(
Offset.zero,
Offset(halfWidth + x, halfHeight + x),
Expand Down
4 changes: 3 additions & 1 deletion lib/src/widgets/help_collection/horizontal_help_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class HorizontalHelpWidget extends StatelessWidget {
// It's fontSize for "Hide" button in options
static const _hideButtonFontSize = 19.2;

static const _additionalSpacing = 14.0;
static const _optionsFontSize = 20.8;
static const _optionHeight = 51.19;
static const _outerHorizontalPadding = 25.6;
Expand Down Expand Up @@ -62,7 +63,8 @@ class HorizontalHelpWidget extends StatelessWidget {
onClose: _controller.goBack,
hideButtonFontSize: _hideButtonFontSize,
chevronSize: const Size.square(9),
chevronPadding: const EdgeInsets.only(left: 6, bottom: 3.5),
chevronPadding: const EdgeInsets.only(left: 15, top: 13.5),
additionalSpacing: _additionalSpacing,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/help_collection/square_help_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SquareHelpWidget extends StatelessWidget {
static const _optionsWidth = 246.39;
static const _lineWidth = 2.0;
static const _chevronSize = 5.625;
static const _chevronOffset = Offset(-1.5, 0);
static const _chevronOffset = Offset(4.5, 0);

/// Constructor
SquareHelpWidget({
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/links_card_widget/links_card_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class _LinksCardButtonState extends State<LinksCardButton> {

static const _defaultFontSize = 16.64;
static const _defaultChevronPadding = EdgeInsets.only(
left: 7,
bottom: 2.5,
left: 13.0,
top: 10.0,
);
static const double _defaultAdditionalSpacing = 4.0;
static const double _defaultAdditionalSpacing = 10.0;

void _onHoverChanged(bool value) {
setState(() {
Expand Down