Skip to content

Commit

Permalink
added firmware update
Browse files Browse the repository at this point in the history
upgraded some dependencies
  • Loading branch information
krjw-eyev committed Nov 7, 2022
1 parent 46b002f commit 6eeaebf
Show file tree
Hide file tree
Showing 32 changed files with 2,059 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-release-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
java-version: '11'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.3'
flutter-version: '3.3.7'
channel: 'stable'
cache: true
- run: flutter build apk --release
Expand All @@ -38,6 +38,6 @@ jobs:
with:
artifacts: 'build/app/outputs/apk/release/skyle_ik-android.zip'
token: ${{ secrets.RELEASES_TOKEN }}
tag: '1.0.0'
tag: '1.1.0'
commit: main
allowUpdates: true
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-release-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.3'
flutter-version: '3.3.7'
channel: 'stable'
architecture: x64
cache: true
Expand All @@ -35,6 +35,6 @@ jobs:
with:
artifacts: 'build/ios/iphoneos/skyle_ik-ios.zip'
token: ${{ secrets.RELEASES_TOKEN }}
tag: '1.0.0'
tag: '1.1.0'
commit: main
allowUpdates: true
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.3'
flutter-version: '3.3.7'
channel: 'stable'
cache: true
- name: Install dependencies
Expand All @@ -35,6 +35,6 @@ jobs:
with:
artifacts: 'build/linux/x64/release/bundle/skyle_ik-linux.zip'
token: ${{ secrets.RELEASES_TOKEN }}
tag: '1.0.0'
tag: '1.1.0'
commit: main
allowUpdates: true
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-release-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.3'
flutter-version: '3.3.7'
channel: 'stable'
architecture: x64
cache: true
Expand All @@ -34,6 +34,6 @@ jobs:
with:
artifacts: 'build/macos/Build/Products/Release/skyle_ik-macos/skyle_ik-macos.zip'
token: ${{ secrets.RELEASES_TOKEN }}
tag: '1.0.0'
tag: '1.1.0'
commit: main
allowUpdates: true
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.3'
flutter-version: '3.3.7'
channel: 'stable'
cache: true
- run: flutter build windows --release
Expand All @@ -33,6 +33,6 @@ jobs:
with:
artifacts: 'build/windows/runner/Release/skyle_ik-windows.zip'
token: ${{ secrets.RELEASES_TOKEN }}
tag: '1.0.0'
tag: '1.1.0'
commit: main
allowUpdates: true
8 changes: 4 additions & 4 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class _SkyleAppState extends ConsumerState<SkyleApp> with WidgetsBindingObserver
} else if (state == AppLifecycleState.resumed) {
// Resume Skyle API
try {
await AppState().et.connect(grpcPort: 50051);
await AppState().et.connect(grpcPort: Configuration.grpcPort);
} catch (e) {
print('Failed to connect Skyle in didChangeAppLifecycle. $e');
}
Expand All @@ -74,7 +74,7 @@ class _SkyleAppState extends ConsumerState<SkyleApp> with WidgetsBindingObserver
} else {
// Start Skyle API
try {
await AppState().et.connect(grpcPort: 50051);
await AppState().et.connect(grpcPort: Configuration.grpcPort);
} catch (e) {
print('Failed to connect Skyle in initState. $e');
}
Expand Down Expand Up @@ -165,8 +165,8 @@ class _SkyleAppState extends ConsumerState<SkyleApp> with WidgetsBindingObserver
print(currentSettings.data);
skyle.IPadOS iPadOS = currentSettings.data!.iPadOS.copyWith();
bool changed = false;
if (iPadOS.isNotZommed != !zoomed) {
iPadOS = iPadOS.copyWith(isNotZommed: !zoomed);
if (iPadOS.isNotZoomed != !zoomed) {
iPadOS = iPadOS.copyWith(isNotZoomed: !zoomed);
changed = true;
print('Reset because of isNotZoomed ${!zoomed}');
}
Expand Down
66 changes: 66 additions & 0 deletions lib/config/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import '../config/routes/main_navigator_state.dart';
import '../config/routes/main_route_information_parser.dart';
import '../config/routes/main_router_delegate.dart';
import '../config/routes/route_state.dart';
import '../data/models/update/release_notes_response.dart';
import '../data/models/update/update_response.dart';
import '../data/models/update/update_state.dart';
import '../data/repositories/update_repository_impl.dart';
import '../domain/repositories/update_repository.dart';
import 'local_settings_notifiers.dart';
import 'positioning_type_notifier.dart';

Expand Down Expand Up @@ -73,6 +78,67 @@ class AppState {
return CalibrationPointsLocalNotifier();
});

final updateRepositoryProvider = Provider<UpdateRepository>((ref) => UpdateRepositoryImpl());

// This provider always takes at least 500 milliseconds to provide a value.
// This is for animation purposes.
final checkForUpdateProvider = FutureProvider.autoDispose.family<skyle.DataState<UpdateResponse>, bool>((ref, beta) async {
ref.keepAlive();
const int minTimeInMilliseconds = 500;
final stopwatch = Stopwatch()..start();
skyle.DataState<UpdateResponse> ret = const skyle.DataFailed<UpdateResponse>('checkForUpdateProvider error: Skyle is not connected.');
final connection = await ref.watch(AppState().connectionProvider.future);
final repository = ref.watch(AppState().updateRepositoryProvider);
if (connection == skyle.Connection.connected) {
try {
final versions = await ref.watch(AppState().versionsProvider.future);
if (versions is skyle.DataSuccess) ret = await repository.tryCheckForUpdate(versions.data!.firmware, versions.data!.serial, beta: beta);
} catch (e) {
ret = skyle.DataFailed<UpdateResponse>(e.toString());
}
}
if (stopwatch.elapsed.inMilliseconds < minTimeInMilliseconds) {
await Future.delayed(Duration(milliseconds: minTimeInMilliseconds - stopwatch.elapsed.inMilliseconds));
}
return ret;
});

final releaseNotesProvider = FutureProvider.autoDispose.family<skyle.DataState<ReleaseNotesResponse>?, bool>((ref, beta) async {
ref.keepAlive();
final connection = await ref.watch(AppState().connectionProvider.future);
final repository = ref.watch(AppState().updateRepositoryProvider);
if (connection == skyle.Connection.connected) {
try {
final update = await ref.watch(AppState().checkForUpdateProvider(beta).future);
final versions = await ref.watch(AppState().versionsProvider.future);
if (update is skyle.DataSuccess && versions is skyle.DataSuccess) return repository.getReleaseNotes(update.data!.version, versions.data!.serial);
} catch (e) {
// skyleLogger?.i(e.toString());
}
}
return null;
});

final isBetaProvider = FutureProvider.autoDispose<skyle.DataState<bool>>((ref) async {
final connection = await ref.watch(AppState().connectionProvider.future);
try {
if (connection == skyle.Connection.connected) {
final versions = await ref.watch(AppState().versionsProvider.future);
if (versions is skyle.DataSuccess) {
return ref.watch(AppState().updateRepositoryProvider).isBeta(versions.data!.serial);
}
return const skyle.DataFailed('Error checking if Skyle isBeta device.');
}
return const skyle.DataFailed('Error checking if Skyle isBeta device: Device disconnected');
} catch (e) {
return skyle.DataFailed('Error checking if Skyle isBeta device: ${e.toString()}');
}
});

final betaFirmwareProvider = StateNotifierProvider<BetaFirmwareLocalNotifier, bool>((ref) {
return BetaFirmwareLocalNotifier();
});

final GazeInteractive gazeInteractive = GazeInteractive();

static final AppState _instance = AppState._internal();
Expand Down
2 changes: 2 additions & 0 deletions lib/config/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ class Configuration {
static String mjpegURL = 'http://${ET.baseURL}:8080/?action=stream';

static const bool simulateET = kDebugMode && false;

static const grpcPort = 50051;
}
21 changes: 21 additions & 0 deletions lib/data/models/update/release_notes_response.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Skyle IK
//
// Created by Konstantin Wachendorff on 07.09.2022.
// Copyright © 2022 eyeV GmbH. All rights reserved.
//

import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'release_notes_response.freezed.dart';
part 'release_notes_response.g.dart';

@freezed
class ReleaseNotesResponse with _$ReleaseNotesResponse {
const factory ReleaseNotesResponse({
required String notes,
required String version,
}) = _ReleaseNotesResponse;

factory ReleaseNotesResponse.fromJson(Map<String, Object?> json) => _$ReleaseNotesResponseFromJson(json);
}
170 changes: 170 additions & 0 deletions lib/data/models/update/release_notes_response.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target

part of 'release_notes_response.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

ReleaseNotesResponse _$ReleaseNotesResponseFromJson(Map<String, dynamic> json) {
return _ReleaseNotesResponse.fromJson(json);
}

/// @nodoc
mixin _$ReleaseNotesResponse {
String get notes => throw _privateConstructorUsedError;
String get version => throw _privateConstructorUsedError;

Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$ReleaseNotesResponseCopyWith<ReleaseNotesResponse> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $ReleaseNotesResponseCopyWith<$Res> {
factory $ReleaseNotesResponseCopyWith(ReleaseNotesResponse value,
$Res Function(ReleaseNotesResponse) then) =
_$ReleaseNotesResponseCopyWithImpl<$Res>;
$Res call({String notes, String version});
}

/// @nodoc
class _$ReleaseNotesResponseCopyWithImpl<$Res>
implements $ReleaseNotesResponseCopyWith<$Res> {
_$ReleaseNotesResponseCopyWithImpl(this._value, this._then);

final ReleaseNotesResponse _value;
// ignore: unused_field
final $Res Function(ReleaseNotesResponse) _then;

@override
$Res call({
Object? notes = freezed,
Object? version = freezed,
}) {
return _then(_value.copyWith(
notes: notes == freezed
? _value.notes
: notes // ignore: cast_nullable_to_non_nullable
as String,
version: version == freezed
? _value.version
: version // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
abstract class _$$_ReleaseNotesResponseCopyWith<$Res>
implements $ReleaseNotesResponseCopyWith<$Res> {
factory _$$_ReleaseNotesResponseCopyWith(_$_ReleaseNotesResponse value,
$Res Function(_$_ReleaseNotesResponse) then) =
__$$_ReleaseNotesResponseCopyWithImpl<$Res>;
@override
$Res call({String notes, String version});
}

/// @nodoc
class __$$_ReleaseNotesResponseCopyWithImpl<$Res>
extends _$ReleaseNotesResponseCopyWithImpl<$Res>
implements _$$_ReleaseNotesResponseCopyWith<$Res> {
__$$_ReleaseNotesResponseCopyWithImpl(_$_ReleaseNotesResponse _value,
$Res Function(_$_ReleaseNotesResponse) _then)
: super(_value, (v) => _then(v as _$_ReleaseNotesResponse));

@override
_$_ReleaseNotesResponse get _value => super._value as _$_ReleaseNotesResponse;

@override
$Res call({
Object? notes = freezed,
Object? version = freezed,
}) {
return _then(_$_ReleaseNotesResponse(
notes: notes == freezed
? _value.notes
: notes // ignore: cast_nullable_to_non_nullable
as String,
version: version == freezed
? _value.version
: version // ignore: cast_nullable_to_non_nullable
as String,
));
}
}

/// @nodoc
@JsonSerializable()
class _$_ReleaseNotesResponse implements _ReleaseNotesResponse {
const _$_ReleaseNotesResponse({required this.notes, required this.version});

factory _$_ReleaseNotesResponse.fromJson(Map<String, dynamic> json) =>
_$$_ReleaseNotesResponseFromJson(json);

@override
final String notes;
@override
final String version;

@override
String toString() {
return 'ReleaseNotesResponse(notes: $notes, version: $version)';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_ReleaseNotesResponse &&
const DeepCollectionEquality().equals(other.notes, notes) &&
const DeepCollectionEquality().equals(other.version, version));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(notes),
const DeepCollectionEquality().hash(version));

@JsonKey(ignore: true)
@override
_$$_ReleaseNotesResponseCopyWith<_$_ReleaseNotesResponse> get copyWith =>
__$$_ReleaseNotesResponseCopyWithImpl<_$_ReleaseNotesResponse>(
this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$_ReleaseNotesResponseToJson(
this,
);
}
}

abstract class _ReleaseNotesResponse implements ReleaseNotesResponse {
const factory _ReleaseNotesResponse(
{required final String notes,
required final String version}) = _$_ReleaseNotesResponse;

factory _ReleaseNotesResponse.fromJson(Map<String, dynamic> json) =
_$_ReleaseNotesResponse.fromJson;

@override
String get notes;
@override
String get version;
@override
@JsonKey(ignore: true)
_$$_ReleaseNotesResponseCopyWith<_$_ReleaseNotesResponse> get copyWith =>
throw _privateConstructorUsedError;
}
Loading

0 comments on commit 6eeaebf

Please sign in to comment.