Files
cutdex/packages/cutdex_ui/lib/src/widgets/app_slider.dart
T
lingjhf 2e0033ce2d
Gitea CI / Build Android APK (pull_request) Canceled after 0s
Gitea CI / Build Windows x64 app (pull_request) Canceled after 0s
Gitea CI / Audit and package Windows x64 (pull_request) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (pull_request) Canceled after 0s
Gitea CI / Gitea CI passed (pull_request) Canceled after 0s
Gitea CI / Check code and tests (pull_request) Canceled after 6m29s
feat(workspace): refresh desktop editing experience and prepare 0.1.2
2026-10-09 01:56:01 +08:00

80 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
class AppSlider extends StatelessWidget {
const AppSlider({
super.key,
required this.value,
required this.onChanged,
this.min = 0,
this.max = 1,
this.divisions,
this.label,
this.focusNode,
this.semanticFormatterCallback,
this.onChangeStart,
this.onChangeEnd,
});
final double value;
final double min;
final double max;
final int? divisions;
final String? label;
final FocusNode? focusNode;
final SemanticFormatterCallback? semanticFormatterCallback;
final ValueChanged<double>? onChanged;
final ValueChanged<double>? onChangeStart;
final ValueChanged<double>? onChangeEnd;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colors = theme.colorScheme;
final accent = colors.primary;
return SizedBox(
height: AppTheme.isCompactInspector(context)
? AppInspectorMetrics.input
: AppTheme.isDesktop(context)
? AppDesktopMetrics.input
: AppControlSize.standard,
child: SliderTheme(
data: SliderTheme.of(context).copyWith(
trackHeight: 4,
trackGap: 0,
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.compact),
activeTrackColor: accent,
inactiveTrackColor: colors.secondaryContainer,
disabledActiveTrackColor: colors.onSurface.withValues(alpha: 0.24),
disabledInactiveTrackColor: colors.outlineVariant,
thumbColor: colors.onPrimary,
disabledThumbColor: colors.onSurface.withValues(alpha: 0.38),
overlayColor: accent.withValues(alpha: 0.14),
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 6,
disabledThumbRadius: 6,
elevation: 1,
pressedElevation: 1,
),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 12),
trackShape: const RoundedRectSliderTrackShape(),
showValueIndicator: ShowValueIndicator.never,
),
child: Slider(
value: value,
min: min,
max: max,
divisions: divisions,
label: label,
focusNode: focusNode,
semanticFormatterCallback: semanticFormatterCallback,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
),
),
);
}
}