Skip to content

Commit

Permalink
fix Github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Nomeyho committed Dec 25, 2019
1 parent 9298b05 commit b50bab0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 12 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,29 @@ jobs:
steps:
# Setup
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '13.x'
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
# Release
- run: |
- name: Create artifact
run: |
rm -rf nomeyho_clock/ios
rm -rf nomeyho_clock/android
rm -rf nomeyho_clock/web
- run: zip -r nomeyho_clock.zip ./nomeyho_clock ./flutter_clock_helper
# Artifacts
- uses: actions/upload-artifact@v1
zip -r nomeyho_clock.zip ./nomeyho_clock ./flutter_clock_helper
- name: Create Release
id: create_release
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: nomeyho_clock.zip
path: nomeyho_clock.zip
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./my-nomeyho_clock.zip
asset_name: my-nomeyho_clock.zip
asset_content_type: application/zip
46 changes: 46 additions & 0 deletions nomeyho_clock/lib/widget/clock_painter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'dart:math' as math;

import 'package:flutter/material.dart';

/// [CustomPainter] that draws a clock hand.
class HandPainter extends CustomPainter {
HandPainter({
@required this.handSize,
@required this.lineWidth,
@required this.angleRadians,
@required this.color,
}) : assert(handSize != null),
assert(lineWidth != null),
assert(angleRadians != null),
assert(color != null),
assert(handSize >= 0.0),
assert(handSize <= 1.0);

double handSize;
double lineWidth;
double angleRadians;
Color color;

@override
void paint(Canvas canvas, Size size) {
final center = (Offset.zero & size).center;
// We want to start at the top, not at the x-axis, so add pi/2.
final angle = angleRadians - math.pi / 2.0;
final length = size.shortestSide * 0.5 * handSize;
final position = center + Offset(math.cos(angle), math.sin(angle)) * length;
final linePaint = Paint()
..color = color
..strokeWidth = lineWidth
..strokeCap = StrokeCap.square;

canvas.drawLine(center, position, linePaint);
}

@override
bool shouldRepaint(HandPainter oldDelegate) {
return oldDelegate.handSize != handSize ||
oldDelegate.lineWidth != lineWidth ||
oldDelegate.angleRadians != angleRadians ||
oldDelegate.color != color;
}
}

0 comments on commit b50bab0

Please sign in to comment.