Skip to content

Commit

Permalink
Merge PR #1753
Browse files Browse the repository at this point in the history
  • Loading branch information
elibon99 committed Jan 9, 2025
2 parents d125a5c + 8320274 commit ebf2689
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FLUTTER=3.24.5
PYVER=3.12.8
FLUTTER=3.27.1
PYVER=3.13.1
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
run: |
brew update
brew install swig
python -m pip install --upgrade pip
pipx install poetry
pipx inject poetry poetry-plugin-export
Expand All @@ -60,7 +61,6 @@ jobs:
env:
SKIP: ${{ steps.cache-helper.outputs.cache-hit == 'true' && 'mypy,flake8,black,bandit' || ''}}
run: |
python -m pip install --upgrade pip
pip install pre-commit
pre-commit run --all-files
flutter test
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
2 changes: 1 addition & 1 deletion build-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if [ "$OS" = "macos" ]; then
poetry run pip download -r $HELPER/cryptography.txt --platform macosx_10_12_universal2 --only-binary :all: --no-deps --dest $HELPER
poetry run pip install -r $HELPER/cryptography.txt --no-cache-dir --no-index --find-links $HELPER
# Combine wheels of pillow to get universal build
poetry run pip download -r $HELPER/pillow.txt --platform macosx_10_10_x86_64 --only-binary :all: --no-deps --dest $HELPER
poetry run pip download -r $HELPER/pillow.txt --platform macosx_10_13_x86_64 --only-binary :all: --no-deps --dest $HELPER
poetry run pip download -r $HELPER/pillow.txt --platform macosx_11_0_arm64 --only-binary :all: --no-deps --dest $HELPER
poetry run pip install delocate
poetry run delocate-merge $HELPER/pillow*.whl
Expand Down
16 changes: 8 additions & 8 deletions helper/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion helper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ packages = [{ include = "helper" }]


[tool.poetry.group.dev.dependencies]
pyinstaller = { version = "^6.0", python = "<3.13" }
pyinstaller = { version = "^6.10", python = "<3.14" }
pytest = "^8.0.0"
mypy = "^1.7.1"
types-Pillow = "^10.2.0.0"
Expand Down
24 changes: 24 additions & 0 deletions lib/app/color_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'dart:ui';

/// This extension is to supplement deprecated_member_use for `value`
/// to convert RGBA into a 32 bit integer.
extension ColorExtension on Color {
static int floatToInt8(double x) {
return (x * 255.0).round() & 0xff;
}

/// A 32 bit value representing this color.
///
/// The bits are assigned as follows:
///
/// * Bits 24-31 are the alpha value.
/// * Bits 16-23 are the red value.
/// * Bits 8-15 are the green value.
/// * Bits 0-7 are the blue value.
int get toInt32 {
return floatToInt8(a) << 24 |
floatToInt8(r) << 16 |
floatToInt8(g) << 8 |
floatToInt8(b) << 0;
}
}
4 changes: 2 additions & 2 deletions lib/app/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import '../../management/models.dart';
import '../core/models.dart';
import '../core/state.dart';
import 'color_extension.dart';

part 'models.freezed.dart';

part 'models.g.dart';

const _listEquality = ListEquality();
Expand Down Expand Up @@ -168,5 +168,5 @@ class _ColorConverter implements JsonConverter<Color?, int?> {
Color? fromJson(int? json) => json != null ? Color(json) : null;

@override
int? toJson(Color? object) => object?.value;
int? toJson(Color? object) => object?.toInt32;
}
3 changes: 2 additions & 1 deletion lib/app/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:shared_preferences/shared_preferences.dart';

import '../core/state.dart';
import '../theme.dart';
import 'color_extension.dart';
import 'features.dart' as features;
import 'logging.dart';
import 'models.dart';
Expand Down Expand Up @@ -159,7 +160,7 @@ final primaryColorProvider = Provider<Color>((ref) {
final customization = ref.watch(keyCustomizationManagerProvider)[serial];
final deviceColor = customization?.color;
if (deviceColor != null) {
prefs.setInt(prefLastUsedColor, deviceColor.value);
prefs.setInt(prefLastUsedColor, deviceColor.toInt32);
return deviceColor;
} else {
prefs.remove(prefLastUsedColor);
Expand Down
4 changes: 2 additions & 2 deletions lib/app/views/app_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ class _AppPageState extends ConsumerState<AppPage> {
? Theme.of(context)
.colorScheme
.onSurfaceVariant
.withOpacity(0.4)
.withValues(alpha: 0.4)
: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.9),
.withValues(alpha: 0.9),
),
overflow: TextOverflow.ellipsis,
),
Expand Down
3 changes: 2 additions & 1 deletion lib/app/views/fs_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class FsDialog extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return Dialog.fullscreen(
backgroundColor: Theme.of(context).colorScheme.surface.withOpacity(0.7),
backgroundColor:
Theme.of(context).colorScheme.surface.withValues(alpha: 0.7),
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expand Down
11 changes: 6 additions & 5 deletions lib/home/views/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:material_symbols_icons/symbols.dart';

import '../../android/state.dart';
import '../../app/color_extension.dart';
import '../../app/message.dart';
import '../../app/models.dart';
import '../../app/state.dart';
Expand Down Expand Up @@ -264,7 +265,7 @@ class _DeviceContent extends ConsumerWidget {
].map((e) => _ColorButton(
color: e,
isSelected:
customColor?.value == e.value,
customColor?.toInt32 == e.toInt32,
onPressed: () {
_updateColor(e, ref, serial);
Navigator.of(context).pop();
Expand Down Expand Up @@ -315,7 +316,7 @@ class _DeviceContent extends ConsumerWidget {
color: Theme.of(context)
.colorScheme
.primary
.withOpacity(0.9)),
.withValues(alpha: 0.9)),
)
],
),
Expand Down Expand Up @@ -438,11 +439,11 @@ class _HeroAvatar extends StatelessWidget {
shape: BoxShape.circle,
gradient: RadialGradient(
colors: [
color.withOpacity(0.6),
color.withOpacity(0.25),
color.withValues(alpha: 0.6),
color.withValues(alpha: 0.25),
(DialogTheme.of(context).backgroundColor ??
theme.dialogBackgroundColor)
.withOpacity(0),
.withValues(alpha: 0),
],
),
),
Expand Down
3 changes: 1 addition & 2 deletions lib/oath/views/account_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

Expand Down Expand Up @@ -42,7 +41,7 @@ class AccountView extends ConsumerStatefulWidget {
}

String _a11yCredentialLabel(String? issuer, String name, String? code) {
return [issuer, name, code].whereNotNull().join(' ');
return [issuer, name, code].nonNulls.join(' ');
}

class _AccountViewState extends ConsumerState<AccountView> {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/file_drop_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FileDropOverlay extends StatelessWidget {
color: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.95),
.withValues(alpha: 0.95),
border: Border.all(color: Theme.of(context).colorScheme.primary),
borderRadius: const BorderRadius.all(Radius.circular(20.0))),
child: Column(
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void Function() showToast(
final Color backgroundColor = isThemeDark
? colorScheme.onSurface
: Color.alphaBlend(
colorScheme.onSurface.withOpacity(0.80), colorScheme.surface);
colorScheme.onSurface.withValues(alpha: 0.80), colorScheme.surface);

final textStyle =
ThemeData(brightness: isThemeDark ? Brightness.light : Brightness.dark)
.textTheme
Expand Down
4 changes: 4 additions & 0 deletions macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ class AppDelegate: FlutterAppDelegate {
// Keep app running if window closes
return false
}

override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
}
Loading

0 comments on commit ebf2689

Please sign in to comment.