mirror of
https://github.com/jagandeepbrar/lunasea.git
synced 2026-08-30 20:24:25 +00:00
* Added RadarrManualImportConfigure for manual import config options * Default bottom modal sheet to not expand * Shrinkwrap modal listviews around content * use keyboardDismissBehavior for all ListView * Ensure keyboard is unfocused when opening the drawer * Fetch and store quality definitions in global Radarr state * Ability to configure language and quality profile for manual import instances * Reworking all search bar implementations, integrated scroll back for Lidarr across module * (ui): [Dashboard] Clean up of dashboard code, integrated scroll to top support * (ui): [SnackBar] Remove all deprecated uses of LSSnackBar, add scrollback for NZBGet, improve error handling in queue * (ui): Removed usage of old StickyListView, ReorderableListView, integrated LunaScaffold into base routes * (flutter): Update packages * (flutter): Remove flutter_sticky_header package * (ui): Remove unused deprecated classes * (chore): Update changelog * (fix): [Dashboard/Calendar] Radarr releases were not considering digital release date * (ui): [Sonarr] Adapted for scroll back to top functionality, remove more deprecated UI elements * (ui): Refactored Tautulli, Removed ALL deprecated UI elements from LunaSea * (ui): Fixed inconsistent usage of material and luna colours across UI * (fix): [Sonarr/Radarr] Do not show "Search For..." button when the query is empty, but there are no results * (chore): Updated changelog * (fix): [Sonarr/Add] Fix search queries not gettting executed * (fix): [Tautulli] Remove unused global state elements * (feat): [UI/AppBar] Ability to hide the leading widget * (fix): [Radarr/Languages] Fix "Unknown" language not being shown in selection dialog * (feat): [Radarr/Import] Ability to search movies to select, toggle real and proper toggles * (chore): Updated packages
134 lines
4.4 KiB
Dart
134 lines
4.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:lunasea/core.dart';
|
|
|
|
class LunaTextInputBar extends StatefulWidget {
|
|
static const double appBarHeight = 62.0;
|
|
static const EdgeInsets appBarMargin = const EdgeInsets.fromLTRB(12.0, 1.0, 12.0, 12.0);
|
|
|
|
final TextEditingController controller;
|
|
final ScrollController scrollController;
|
|
final TextInputAction action;
|
|
final TextInputType keyboardType;
|
|
final Iterable<String> autofillHints;
|
|
final String labelText;
|
|
final IconData labelIcon;
|
|
final bool autofocus;
|
|
final bool obscureText;
|
|
final bool isFormField;
|
|
final void Function(String) onChanged;
|
|
final void Function(String) onSubmitted;
|
|
final String Function(String) validator;
|
|
final EdgeInsets margin;
|
|
|
|
LunaTextInputBar({
|
|
@required this.controller,
|
|
this.scrollController,
|
|
this.onChanged,
|
|
this.onSubmitted,
|
|
this.validator,
|
|
this.autofillHints,
|
|
this.action = TextInputAction.search,
|
|
this.keyboardType = TextInputType.text,
|
|
this.labelText,
|
|
this.labelIcon = Icons.search,
|
|
this.margin = LunaUI.MARGIN_CARD,
|
|
this.autofocus = false,
|
|
this.obscureText = false,
|
|
this.isFormField = false,
|
|
}) {
|
|
assert(controller != null);
|
|
}
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => _State();
|
|
}
|
|
|
|
class _State extends State<LunaTextInputBar> {
|
|
bool _isFocused = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => LunaCard(
|
|
context: context,
|
|
margin: widget.margin,
|
|
child: FocusScope(
|
|
child: Focus(
|
|
onFocusChange: (value) => setState(() => _isFocused = value),
|
|
child: widget.isFormField ? _isForm : _isNotForm,
|
|
),
|
|
),
|
|
color: Theme.of(context).canvasColor,
|
|
);
|
|
|
|
TextStyle get _sharedTextStyle => TextStyle(
|
|
color: Colors.white,
|
|
fontSize: LunaUI.FONT_SIZE_SUBTITLE,
|
|
);
|
|
|
|
InputDecoration get _sharedInputDecoration => InputDecoration(
|
|
labelText: widget.labelText ?? 'lunasea.SearchTextBar'.tr(),
|
|
labelStyle: TextStyle(
|
|
color: Colors.white54,
|
|
decoration: TextDecoration.none,
|
|
fontSize: LunaUI.FONT_SIZE_SUBTITLE,
|
|
),
|
|
suffixIcon: AnimatedOpacity(
|
|
child: GestureDetector(
|
|
child: Icon(
|
|
Icons.close,
|
|
color: LunaColours.accent,
|
|
size: 24.0,
|
|
),
|
|
onTap: widget.onChanged == null ? null : () {
|
|
widget.scrollController?.lunaAnimateToStart();
|
|
widget.controller.text = '';
|
|
widget.onChanged('');
|
|
}
|
|
),
|
|
opacity: !_isFocused || widget.controller.text == '' ? 0.0 : 1.0,
|
|
duration: Duration(milliseconds: 200),
|
|
),
|
|
icon: Padding(
|
|
child: Icon(
|
|
widget.labelIcon,
|
|
color: LunaColours.accent,
|
|
),
|
|
padding: EdgeInsets.only(left: 16.0),
|
|
),
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.symmetric(vertical: 8.0),
|
|
);
|
|
|
|
TextFormField get _isForm => TextFormField(
|
|
autofillHints: widget.autofillHints,
|
|
autofocus: widget.autofocus,
|
|
controller: widget.controller,
|
|
decoration: _sharedInputDecoration,
|
|
style: _sharedTextStyle,
|
|
cursorColor: LunaColours.accent,
|
|
textInputAction: widget.action,
|
|
obscureText: widget.obscureText,
|
|
autocorrect: false,
|
|
keyboardType: widget.keyboardType,
|
|
validator: widget?.validator,
|
|
onTap: widget.scrollController?.lunaAnimateToStart,
|
|
onChanged: widget.onChanged == null ? null : widget.onChanged,
|
|
onFieldSubmitted: widget?.onSubmitted,
|
|
);
|
|
|
|
TextField get _isNotForm => TextField(
|
|
autofillHints: widget.autofillHints,
|
|
autofocus: widget.autofocus,
|
|
controller: widget.controller,
|
|
decoration: _sharedInputDecoration,
|
|
style: _sharedTextStyle,
|
|
cursorColor: LunaColours.accent,
|
|
textInputAction: widget.action,
|
|
obscureText: widget.obscureText,
|
|
autocorrect: false,
|
|
keyboardType: widget.keyboardType,
|
|
onTap: widget.scrollController?.lunaAnimateToStart,
|
|
onChanged: widget.onChanged == null ? null : widget.onChanged,
|
|
onSubmitted: widget?.onSubmitted,
|
|
);
|
|
}
|