Files
sm-emby-share/lib/features/settings/widgets/settings_rows.dart
T
2026-07-14 11:11:36 +08:00

149 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import '../../../core/contracts/player_gestures.dart';
import '../../../shared/widgets/setting_select.dart';
import '../../player/gestures/gesture_action.dart' as g;
import '../utils/settings_labels.dart';
class SeekDurationRow extends StatelessWidget {
final String title;
final int seconds;
final ValueChanged<int> onChanged;
static const _options = [5, 10, 15, 20, 30, 45, 60, 90, 120];
const SeekDurationRow({
super.key,
required this.title,
required this.seconds,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: Row(
children: [
Expanded(
child: Text(
title,
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
),
),
),
SettingSelect<int>(
value: seconds,
options: _options,
labelOf: (value) => '$value',
onChanged: (v) {
if (v != null) onChanged(v);
},
),
],
),
);
}
}
class GestureSpeedRow extends StatelessWidget {
final String title;
final double value;
final ValueChanged<double> onChanged;
static const _options = [
0.5,
0.75,
1.0,
1.25,
1.5,
1.75,
2.0,
2.5,
3.0,
4.0,
8.0,
];
const GestureSpeedRow({
super.key,
required this.title,
required this.value,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: Row(
children: [
Expanded(
child: Text(
title,
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
),
),
),
SettingSelect<double>(
value: value,
options: _options,
labelOf: formatMenuSpeed,
onChanged: (v) {
if (v != null) onChanged(v);
},
),
],
),
);
}
}
class GestureActionRow extends StatelessWidget {
final String title;
final g.GestureKind kind;
final GestureAction value;
final ValueChanged<GestureAction> onChanged;
const GestureActionRow({
super.key,
required this.title,
required this.kind,
required this.value,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final options = g.allowedActionsFor(kind);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
child: Row(
children: [
Expanded(
child: Text(
title,
style: theme.textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
),
),
),
SettingSelect<GestureAction>(
value: value,
options: options,
labelOf: g.gestureActionLabel,
onChanged: (v) {
if (v != null) onChanged(v);
},
),
],
),
);
}
}