Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
channel: stable
- name: Install dependencies
run: flutter pub get
- name: Check Dart formatting
run: dart format --output=none --set-exit-if-changed .
- name: Run Dart linter
run: flutter analyze --fatal-infos
- name: Build web app
run: flutter build web --release --dart-define=BUILD_NUMBER=${{ github.run_number }} --base-href /
- name: Upload Pages artifact
Expand All @@ -43,4 +47,4 @@ jobs:
uses: actions/configure-pages@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
25 changes: 25 additions & 0 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PR CI

on:
pull_request:

permissions:
contents: read

jobs:
checks-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install dependencies
run: flutter pub get
- name: Check Dart formatting
run: dart format --output=none --set-exit-if-changed .
- name: Run Dart linter
run: flutter analyze --fatal-infos
- name: Build web app
run: flutter build web --release --dart-define=BUILD_NUMBER=${{ github.run_number }} --base-href /
38 changes: 19 additions & 19 deletions lib/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ class _MainScreenState extends State<MainScreen> {
String buildScreenshotName(int width, int height) {
final now = DateTime.now();
return "picoTracker-"
"${isAdvanceMode ? "Advance-" : ""}"
"${now.year}"
"${two(now.month)}"
"${two(now.day)}"
"${two(now.hour)}"
"${two(now.minute)}"
"${two(now.second)}"
".png";
"${isAdvanceMode ? "Advance-" : ""}"
"${now.year}"
"${two(now.month)}"
"${two(now.day)}"
"${two(now.hour)}"
"${two(now.minute)}"
"${two(now.second)}"
".png";
}

Future<void> captureScreenshot() async {
Expand All @@ -96,19 +96,19 @@ class _MainScreenState extends State<MainScreen> {

isCapturing = true;
try {
final boundary = repaintBoundaryKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;
final boundary = repaintBoundaryKey.currentContext?.findRenderObject()
as RenderRepaintBoundary?;
if (boundary == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Failed to capture screenshot')),
);
return;
}

final targetWidth =
isAdvanceMode ? kAdvanceScreenWidth : kScreenWidth;
final targetHeight =
isAdvanceMode ? kAdvanceScreenHeight : kScreenHeight;
final ratio = min(targetWidth / boundary.size.width, targetHeight / boundary.size.height);
final targetWidth = isAdvanceMode ? kAdvanceScreenWidth : kScreenWidth;
final targetHeight = isAdvanceMode ? kAdvanceScreenHeight : kScreenHeight;
final ratio = min(targetWidth / boundary.size.width,
targetHeight / boundary.size.height);

final image = await boundary.toImage(pixelRatio: ratio);
final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Expand Down Expand Up @@ -191,8 +191,8 @@ class _MainScreenState extends State<MainScreen> {
decoration: BoxDecoration(
color: !isAdvanceMode ? kKey : kKeyLow,
border: Border.all(
color: Colors.amberAccent.withOpacity(
!isAdvanceMode ? 1.0 : 0.5),
color: Colors.amberAccent.withValues(
alpha: !isAdvanceMode ? 1.0 : 0.5),
width: 2,
),
),
Expand Down Expand Up @@ -220,8 +220,8 @@ class _MainScreenState extends State<MainScreen> {
decoration: BoxDecoration(
color: isAdvanceMode ? kKey : kKeyLow,
border: Border.all(
color: Colors.amberAccent.withOpacity(
isAdvanceMode ? 1.0 : 0.5),
color: Colors.amberAccent.withValues(
alpha: isAdvanceMode ? 1.0 : 0.5),
width: 2,
),
),
Expand Down Expand Up @@ -266,4 +266,4 @@ class _MainScreenState extends State<MainScreen> {
),
);
}
}
}
2 changes: 1 addition & 1 deletion lib/screen_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const int kStandardWindowWidth = 640;
const int kStandardWindowHeight = 480;

const Color kKey = Color.fromARGB(255, 35, 13, 73);
const Color kKeyLow = Color.fromARGB(255, 20, 7, 40);
const Color kKeyLow = Color.fromARGB(255, 20, 7, 40);
1 change: 0 additions & 1 deletion lib/serialport_native.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class SerialPortHandler {
}
}

// TODO:
bool isAdvance() => false;

void _initPort() {
Expand Down
19 changes: 9 additions & 10 deletions lib/widgets/pico_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class PicoScreenPainter extends CustomPainter {
final rectPaint = Paint()..isAntiAlias = false;
final cellBgPaint = Paint()..isAntiAlias = false;
final deviceScreenWidth =
(isAdvance ? kAdvanceScreenWidth : kScreenWidth).toDouble();
(isAdvance ? kAdvanceScreenWidth : kScreenWidth).toDouble();
final deviceScreenHeight =
(isAdvance ? kAdvanceScreenHeight : kScreenHeight).toDouble();
(isAdvance ? kAdvanceScreenHeight : kScreenHeight).toDouble();
final double scaleX = size.width / deviceScreenWidth;
final double scaleY = size.height / deviceScreenHeight;

Expand Down Expand Up @@ -197,14 +197,13 @@ class _PicoScreenState extends State<PicoScreen> {
style: Theme.of(context).textTheme.headlineSmall),
),
),
SizedBox(
width: (widget.isAdvanceMode
? kAdvanceScreenWidth
: kScreenWidth * 2)
.toDouble(),
height: (widget.isAdvanceMode
? kAdvanceScreenHeight
: kScreenHeight * 2)
SizedBox(
width:
(widget.isAdvanceMode ? kAdvanceScreenWidth : kScreenWidth * 2)
.toDouble(),
height: (widget.isAdvanceMode
? kAdvanceScreenHeight
: kScreenHeight * 2)
.toDouble(),
child: RepaintBoundary(
key: widget.repaintBoundaryKey,
Expand Down
10 changes: 5 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev"
source: hosted
version: "1.16.0"
version: "1.17.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -228,10 +228,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev"
source: hosted
version: "0.7.6"
version: "0.7.7"
udev:
dependency: "direct main"
description:
Expand All @@ -257,7 +257,7 @@ packages:
source: hosted
version: "15.0.2"
web:
dependency: transitive
dependency: "direct main"
description:
name: web
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies:
flutter_libserialport: ^0.4.0
webserial: ^1.2.0
udev: ^0.0.3
web: ^1.1.1

dev_dependencies:
flutter_test:
Expand Down