d3b6026bfd
- Filled empty libs/hbb_common/ submodule (cloned from rustdesk/hbb_common) - Patched Flutter 3.44 / Dart 3.12 compatibility: * flutter/lib/generated_bridge.dart: asTypedList with cast<>, DartPort=Int64 * flutter/lib/common.dart: DialogTheme->DialogThemeData, TabBarTheme->TabBarThemeData * flutter/pubspec.yaml: extended_text 14.0.0->15.0.2, google_fonts override 5.0.0 * flutter/macos/Runner/Configs/Release.xcconfig: EXCLUDED_ARCHS=x86_64 - Build verified: cargo check + cargo build --features flutter + cargo build --release --features flutter - Verified flutter build macos --debug and --release both produce working .app - Verified .dmg installer (27MB arm64) created via hdiutil - Build deps: Xcode 26.5, CocoaPods 1.16.2, Flutter 3.44, VCPKG arm64-osx
35 lines
1.4 KiB
Dart
35 lines
1.4 KiB
Dart
import 'package:flutter_hbb/consts.dart';
|
|
import 'package:flutter_hbb/models/platform_model.dart';
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
/// Clamp custom scale percent to supported bounds.
|
|
/// Keep this in sync with the slider's minimum in the desktop toolbar UI.
|
|
///
|
|
/// This function exists to ensure consistent clamping behavior across the app
|
|
/// and to provide a single point of reference for the valid scale range.
|
|
int clampCustomScalePercent(int percent) {
|
|
return percent.clamp(kScaleCustomMinPercent, kScaleCustomMaxPercent);
|
|
}
|
|
|
|
/// Parse a string percent and clamp. Defaults to 100 when invalid.
|
|
int parseCustomScalePercent(String? s, {int defaultPercent = 100}) {
|
|
final parsed = int.tryParse(s ?? '') ?? defaultPercent;
|
|
return clampCustomScalePercent(parsed);
|
|
}
|
|
|
|
/// Convert a percent value to scale factor after clamping.
|
|
double percentToScale(int percent) => clampCustomScalePercent(percent) / 100.0;
|
|
|
|
/// Fetch, parse and clamp the custom scale percent for a session.
|
|
Future<int> getSessionCustomScalePercent(UuidValue sessionId) async {
|
|
final opt = await bind.sessionGetFlutterOption(
|
|
sessionId: sessionId, k: kCustomScalePercentKey);
|
|
return parseCustomScalePercent(opt);
|
|
}
|
|
|
|
/// Fetch and compute the custom scale factor for a session.
|
|
Future<double> getSessionCustomScale(UuidValue sessionId) async {
|
|
final p = await getSessionCustomScalePercent(sessionId);
|
|
return percentToScale(p);
|
|
}
|