mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-11 17:29:26 +02:00
v1.1.11: Android TV UX - Extend controls timer + Fix settings keyboard
- Extended player controls visibility from 4s to 10s - Converted _FilterInput to TV-friendly StatefulWidget - Added ExcludeFocus + readOnly pattern to prevent keyboard auto-open - Settings fields now only activate on OK/Enter press
This commit is contained in:
1 parent
cd2e4df2a8
commit
332295a57a
2 files changed
+115
-38
No files matched your search
@@ -76,7 +76,7 @@ class _NativePlayerScreenState extends ConsumerState<NativePlayerScreen> with Wi
|
|||||||
void _resetControlsTimer() {
|
void _resetControlsTimer() {
|
||||||
_controlsTimer?.cancel();
|
_controlsTimer?.cancel();
|
||||||
if (_showControls && _isPlaying) {
|
if (_showControls && _isPlaying) {
|
||||||
_controlsTimer = Timer(const Duration(seconds: 4), () {
|
_controlsTimer = Timer(const Duration(seconds: 10), () {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() => _showControls = false);
|
setState(() => _showControls = false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import '../../../providers/mobile_settings_providers.dart';
|
import '../../../providers/mobile_settings_providers.dart';
|
||||||
@@ -108,7 +109,7 @@ class _MobileSettingsTabState extends ConsumerState<MobileSettingsTab> {
|
|||||||
),
|
),
|
||||||
SizedBox(height: 4),
|
SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
'Version 1.1.10',
|
'Version 1.1.11',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: AppColors.textSecondary,
|
color: AppColors.textSecondary,
|
||||||
@@ -312,7 +313,7 @@ class _SectionHeader extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FilterInput extends StatelessWidget {
|
class _FilterInput extends StatefulWidget {
|
||||||
final String label;
|
final String label;
|
||||||
final String hint;
|
final String hint;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
@@ -327,44 +328,120 @@ class _FilterInput extends StatelessWidget {
|
|||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_FilterInput> createState() => _FilterInputState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FilterInputState extends State<_FilterInput> {
|
||||||
|
late FocusNode _navFocus;
|
||||||
|
late FocusNode _inputFocus;
|
||||||
|
bool _isEditing = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_navFocus = FocusNode();
|
||||||
|
_inputFocus = FocusNode();
|
||||||
|
|
||||||
|
_inputFocus.addListener(() {
|
||||||
|
if (!_inputFocus.hasFocus && _isEditing) {
|
||||||
|
setState(() => _isEditing = false);
|
||||||
|
_navFocus.requestFocus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_navFocus.dispose();
|
||||||
|
_inputFocus.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _activateInput() {
|
||||||
|
setState(() => _isEditing = true);
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
_inputFocus.requestFocus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Focus(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
focusNode: _navFocus,
|
||||||
children: [
|
onKeyEvent: (node, event) {
|
||||||
Row(
|
if (event is KeyDownEvent) {
|
||||||
children: [
|
final key = event.logicalKey;
|
||||||
Icon(icon, size: 18, color: AppColors.primary),
|
if (key == LogicalKeyboardKey.select ||
|
||||||
const SizedBox(width: 8),
|
key == LogicalKeyboardKey.enter ||
|
||||||
Text(label,
|
key == LogicalKeyboardKey.space) {
|
||||||
style: const TextStyle(
|
_activateInput();
|
||||||
fontSize: 14,
|
return KeyEventResult.handled;
|
||||||
fontWeight: FontWeight.w500,
|
}
|
||||||
color: AppColors.textPrimary,
|
}
|
||||||
|
return KeyEventResult.ignored;
|
||||||
|
},
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final isFocused = Focus.of(context).hasFocus;
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(widget.icon, size: 18, color: isFocused ? AppColors.primary : AppColors.textSecondary),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(widget.label,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: isFocused ? AppColors.primary : AppColors.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
],
|
GestureDetector(
|
||||||
),
|
onTap: _activateInput,
|
||||||
const SizedBox(height: 8),
|
child: Container(
|
||||||
TextField(
|
decoration: BoxDecoration(
|
||||||
controller: controller,
|
border: isFocused ? Border.all(color: AppColors.primary, width: 2) : null,
|
||||||
style: const TextStyle(fontSize: 14, color: AppColors.textPrimary),
|
borderRadius: BorderRadius.circular(8),
|
||||||
decoration: InputDecoration(
|
),
|
||||||
isDense: true,
|
child: ExcludeFocus(
|
||||||
hintText: hint,
|
excluding: !_isEditing,
|
||||||
hintStyle: const TextStyle(color: AppColors.textTertiary),
|
child: TextField(
|
||||||
filled: true,
|
controller: widget.controller,
|
||||||
fillColor: AppColors.background,
|
focusNode: _inputFocus,
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
readOnly: !_isEditing,
|
||||||
horizontal: 12, vertical: 10),
|
showCursor: _isEditing,
|
||||||
border: OutlineInputBorder(
|
style: const TextStyle(fontSize: 14, color: AppColors.textPrimary),
|
||||||
borderRadius: BorderRadius.circular(8),
|
decoration: InputDecoration(
|
||||||
borderSide: BorderSide.none,
|
isDense: true,
|
||||||
),
|
hintText: widget.hint,
|
||||||
),
|
hintStyle: const TextStyle(color: AppColors.textTertiary),
|
||||||
onChanged: onChanged,
|
filled: true,
|
||||||
),
|
fillColor: AppColors.background,
|
||||||
],
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12, vertical: 10),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onChanged: widget.onChanged,
|
||||||
|
onSubmitted: (_) {
|
||||||
|
setState(() => _isEditing = false);
|
||||||
|
_navFocus.requestFocus();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user