Files
lunasea/lib/core/ui/input_bar.dart
Jagandeep Brar f35c4bf571 [Release] v5.0.0 (50000011) (#343)
* [Radarr] Added very basic localization file for testing

* Added minimal LunaSea localization file

* Translations update from Weblate (#325)

* Added translation using Weblate (German)

* Translated using Weblate (German)

Currently translated at 25.0% (1 of 4 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/de/

* Added translation using Weblate (French)

* Translated using Weblate (French)

Currently translated at 25.0% (1 of 4 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Translated using Weblate (French)

Currently translated at 100.0% (4 of 4 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Deleted translation using Weblate (German)

Co-authored-by: Jagandeep Brar <me@jagandeepbrar.io>
Co-authored-by: Antoine C <contact+weblate@antoinecardon.fr>

* [Localization] Updated keys

* [Strings] Removed internal constant LunaSea to ease localization efforts

* Added translation using Weblate (French)

* Translated using Weblate (French)

Currently translated at 100.0% (1 of 1 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/fr/

* [Radarr] Added additional localization strings

* [Locale/Radarr] Additional strings

* Added translation using Weblate (Norwegian Bokmål)

* Added translation using Weblate (Norwegian Bokmål)

* Translated using Weblate (French)

Currently translated at 100.0% (11 of 11 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 100.0% (1 of 1 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/nb_NO/

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 90.9% (10 of 11 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/nb_NO/

* Translated using Weblate (French)

Currently translated at 100.0% (11 of 11 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* [localizations] sort keys

* [Packages] Migration to Fluttter v2 and NNBD Compatibility (#329)

* Updated packages
* Added system level Firebase Crashlytics to replace Sentry
* Started migration to crashlytics
* [Crashlytics] Adjusted dialog to reflect analytics, add crash button
* [Settings] Removed test crash tile
* [Changelog] Pull changelog version and build from application package
* Added easy_localization package
* Added stub localization handler

* [Localization] Added package and assembly script (#330)

* Updated packages
* Added system level Firebase Crashlytics to replace Sentry
* Started migration to crashlytics
* [Crashlytics] Adjusted dialog to reflect analytics, add crash button
* [Settings] Removed test crash tile
* [Changelog] Pull changelog version and build from application package
* Added easy_localization package
* Added stub localization handler
* [Localization] Added easy_localization package, added script to concat all localization files

* Removed license shield

* [Localization] Integrated system localization handling (#331)

* [Localization] use dash delimiter

* Translated using Weblate (English)

Currently translated at 100.0% (11 of 11 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/en/

* [Localization] Added ability to switch languages, updated Radarr localization (#333)

* [Scripts, Localization] Updated prepare script to print nicer JSON, add additional strings for Radarr
* Updated localizations, switch remaining Radarr strings that are available

* Translated using Weblate (French)

Currently translated at 100.0% (12 of 12 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 100.0% (12 of 12 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/nb_NO/

* Generated new local assets

* [radarr/add_movie] Strings adapted for localizations and added to localization files

* Translated using Weblate (English)

Currently translated at 100.0% (2 of 2 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/en/

* [Localizations] Rebuild

* Translated using Weblate (French)

Currently translated at 100.0% (18 of 18 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Translated using Weblate (French)

Currently translated at 100.0% (2 of 2 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/fr/

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 100.0% (2 of 2 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/nb_NO/

* [Radarr/Add Movie] Adapted for localized strings

* [Radarr/Add Details] Adapted for localized strings

* [Radarr/Edit Movie] Adapted for localized strings

* Translated using Weblate (French)

Currently translated at 100.0% (3 of 3 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/fr/

* Translated using Weblate (French)

Currently translated at 100.0% (25 of 25 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* [Chore] Rebuilt localizations

* [Radarr/Dialogs] Updated a few dialogs to reflect localized titles

* [Localization] Ability to disable localization options internally

* [DateTime] Show "Just Now" when time difference is under 10 seconds

* [Search] Switch to new XML parsing package/engine

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 96.7% (30 of 31 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/nb_NO/

* Translated using Weblate (French)

Currently translated at 100.0% (31 of 31 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Translated using Weblate (French)

Currently translated at 100.0% (4 of 4 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/fr/

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 100.0% (4 of 4 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/nb_NO/

* [Localization] (chore) Rebuild localization

* [Chore] Moved localization to system folder

* Added translation using Weblate (Swedish)

* Added translation using Weblate (Swedish)

* Translated using Weblate (Swedish)

Currently translated at 100.0% (4 of 4 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/sv/

* Translated using Weblate (Swedish)

Currently translated at 100.0% (31 of 31 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/sv/

* [Localization] Added support for Swedish (sv)

* [Radarr/Types] Adapted all type readable strings for localization

* [Radarr] Continued work on adapting for localization

* Translated using Weblate (French)

Currently translated at 100.0% (71 of 71 strings)

Translation: LunaSea/Radarr
Translate-URL: https://hosted.weblate.org/projects/lunasea/radarr/fr/

* Translated using Weblate (French)

Currently translated at 100.0% (9 of 9 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/fr/

* [Localization] (chore) Build localization

* [Chore] Cleanup, move and adapt drawer to LunaUI

* [Drawer] Cleanup drawer builder

* Translated using Weblate (English)

Currently translated at 100.0% (9 of 9 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/en/

* Translated using Weblate (English)

Currently translated at 100.0% (10 of 10 strings)

Translation: LunaSea/LunaSea
Translate-URL: https://hosted.weblate.org/projects/lunasea/lunasea/en/

* [UI] Move "luna_ui" to "ui", old "ui" to "deprecated_ui"

* [-arr/Add] Tags set when adding content are now stored in the database

* [-arr/Links] Added Trakt link, normalize sizes, update TMDB logo

* Add weblate link, disable additional languages on release mode, updated changelog

Co-authored-by: Weblate (bot) <hosted@weblate.org>
Co-authored-by: Antoine C <contact+weblate@antoinecardon.fr>
Co-authored-by: Allan Nordhøy <epost@anotheragency.no>
Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: Patrik Hauguth <patrik.hauguth@gmail.com>
2021-03-07 20:30:58 -06:00

125 lines
4.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:lunasea/core.dart';
class LunaTextInputBar extends StatefulWidget {
final TextEditingController controller;
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.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) => LSCard(
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: Constants.UI_FONT_SIZE_SUBTITLE,
);
InputDecoration get _sharedInputDecoration => InputDecoration(
labelText: widget.labelText ?? 'lunasea.SearchTextBar'.tr(),
labelStyle: TextStyle(
color: Colors.white54,
decoration: TextDecoration.none,
fontSize: Constants.UI_FONT_SIZE_SUBTITLE,
),
suffixIcon: AnimatedOpacity(
child: GestureDetector(
child: Icon(
Icons.close,
color: LunaColours.accent,
size: 24.0,
),
onTap: widget.onChanged == null ? null : () {
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,
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,
onChanged: widget.onChanged == null ? null : widget.onChanged,
onSubmitted: widget?.onSubmitted,
);
}