Files
lunasea/lib/modules/settings/core/pages/headers.dart
Jagandeep Brar dec1845764 [Release] (chore): Dirty v5.0.0+50000013 (#382) (#383)
* [iOS/Build] Add GoogleUtilities pod to prevent archive errors

* (chore) version bump

* [Git] Initialize blackbox

* [Git] Initialize blackbox

* [Git/Blackbox] Add me@jagandeepbrar.io as admin

* registered in blackbox: ios/ExportOptions.plist

* registered in blackbox: ios/GoogleService-Info.plist

* registered in blackbox: android/key.properties

* registered in blackbox: android/app/google-services.json

* Re-encrypted keys

* registered in blackbox: android/key.jks

* Updated key.properties, re-encrypted

* [Android/Keystore] Update same key.properties

* [Tautulli/Activity] Incorrectly localized "Transcodes" string

* [Radarr, UI] Implemented quick manual import, Implemented new design of ExpandableTile across UI (#378)

* Use local path for radarr package

* [Radarr/Manual Import] Browse filesystem, trigger quick import

* [UI/Buttons] Normalize the height of all buttons

* Update packages

* [ListView] Exposed itemExtent property

* [Lidarr/Releases] Move from LSExpandable to LunaExpandableListTile implementation

* [Tautulli/Logs] Use the new expandable table card styling

* [SABnzbd/History] Use the newer expandable table card styling

* [NZBGet/History] Use the newer expandable table card styling

* [UI/Button] Reduce size of the loader and icon to closer match text size

* [Sonarr/Releases] Use the newer expandable table card styling

* [Sonarr/Episodes] Use the newer expandable table card styling

* [UI/Table] Safe-guard title and body text, show emdash when receiving null data

* [Radarr/Details] Show monitor status and properly update the overview table on edit or monitor status changes

* Updated changelog

* [Sonarr/Queue & Episodes] Cleaned up implementation of expandable tile

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 100.0% (14 of 14 strings)

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

* Translated using Weblate (Swedish)

Currently translated at 100.0% (14 of 14 strings)

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

* Translated using Weblate (German)

Currently translated at 100.0% (68 of 68 strings)

Translation: LunaSea/Tautulli
Translate-URL: https://hosted.weblate.org/projects/lunasea/tautulli/de/

* Translated using Weblate (Norwegian Bokmål)

Currently translated at 80.8% (55 of 68 strings)

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

* Translated using Weblate (Swedish)

Currently translated at 100.0% (68 of 68 strings)

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

* Translated using Weblate (Russian)

Currently translated at 57.3% (39 of 68 strings)

Translation: LunaSea/Tautulli
Translate-URL: https://hosted.weblate.org/projects/lunasea/tautulli/ru/

* (chore) Build localizations

* [Tautulli/Webhooks] Implement webhook data handlers for all Tautulli webhooks (#380)

* [Tautulli/Webhooks] Handle transcode decision change and watched event types
* [Radarr/Sonarr] Safe-guard webhooks by pushing the home route on invalid received data blocks
* [Tautulli/Webhooks] Implemented all webhooks

* Translated using Weblate (French)

Currently translated at 100.0% (78 of 78 strings)

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

* Translated using Weblate (German)

Currently translated at 100.0% (78 of 78 strings)

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

* Translated using Weblate (Russian)

Currently translated at 92.8% (13 of 14 strings)

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

* [Release] (chore): Dirty v5.0.0+50000013 (#382)

* [Radarr/Manual Import] Add search bar for host system path, add stub manual import page

* [Radarr/Manual Import] Change path bar text to "File Browser..."

* [Radarr/Manual Import] Pass "/" if textController text is null

* [Radarr/Import] Stub details state

* [Database] Correctly register LunaIndexerIcon hive adapter

* [Radarr/Import] Filter directories when typing path, Fetch manual import results with stub cards

* [UI/Bottom Bar] Abstract bottom action bar, use on add movie page

* [UI/Navigation Bar] Add option to attach stickied top actions to navigation bar

* [Radarr/Edit] Use stickied bottom action bar for buttons

* [Radarr/Details] use sticky navigation actions for interactive and automatic search

* [Dialogs] CheckboxTiles were padded too aggressively in the X-axis

* [Sentry] Remove remaining references to Sentry

* (chore) Build localizations

* (chore) Update changelog

* Preparing to shift GitHub repository structure

Co-authored-by: Allan Nordhøy <epost@anotheragency.no>
Co-authored-by: Patrik Hauguth <patrik.hauguth@gmail.com>
Co-authored-by: cpt-kuesel <jln.sltr@pm.me>
Co-authored-by: Artem <KovalevArtem.ru@gmail.com>
Co-authored-by: Antoine C <contact+weblate@antoinecardon.fr>
2021-03-24 08:12:41 -05:00

125 lines
4.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:lunasea/core.dart';
import 'package:lunasea/modules.dart';
import 'package:lunasea/modules/settings.dart';
class SettingsHeaderRoute extends StatefulWidget {
final LunaModule module;
SettingsHeaderRoute({
Key key,
@required this.module,
}) : super(key: key);
@override
State<StatefulWidget> createState() => _State();
}
class _State extends State<SettingsHeaderRoute> with LunaScrollControllerMixin {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
if(widget.module == null) return LunaInvalidRoute(
title: 'Custom Headers',
message: 'Unknown Module',
);
return Scaffold(
key: _scaffoldKey,
appBar: _appBar(),
body: _body(),
);
}
Widget _appBar() {
return LunaAppBar(
title: 'Custom Headers',
scrollControllers: [scrollController],
);
}
Widget _body() {
return ValueListenableBuilder(
valueListenable: Database.profilesBox.listenable(),
builder: (context, profile, _) => LunaListView(
controller: scrollController,
children: [
if((_headers() ?? {}).isEmpty) _noHeadersFound(),
..._headerList(),
_addHeader(),
],
),
);
}
Widget _noHeadersFound() => LunaMessage.inList(text: 'No Headers Added');
List<LunaListTile> _headerList() {
Map<String, dynamic> headers = (_headers() ?? {}).cast<String, dynamic>();
List<String> _sortedKeys = headers.keys.toList()..sort();
return _sortedKeys.map<LunaListTile>((key) => _headerTile(key, headers[key])).toList();
}
LunaListTile _headerTile(String key, String value) {
return LunaListTile(
context: context,
title: LunaText.title(text: key),
subtitle: LunaText.subtitle(text: value),
trailing: LunaIconButton(
icon: Icons.delete,
color: LunaColours.red,
onPressed: () async {
await HeaderUtility().deleteHeader(context, headers: _headers(), key: key);
_resetState();
}
),
);
}
Widget _addHeader() {
return LunaButtonContainer(
children: [
LunaButton.text(
text: 'Add Header',
onTap: () async {
await HeaderUtility().addHeader(context, headers: _headers());
_resetState();
}
),
],
);
}
Map<dynamic, dynamic> _headers() {
switch(widget.module) {
case LunaModule.DASHBOARD: throw Exception('Dashboard does not have a headers page');
case LunaModule.LIDARR: return Database.currentProfileObject.lidarrHeaders;
case LunaModule.RADARR: return Database.currentProfileObject.radarrHeaders;
case LunaModule.SONARR: return Database.currentProfileObject.sonarrHeaders;
case LunaModule.SABNZBD: return Database.currentProfileObject.sabnzbdHeaders;
case LunaModule.NZBGET: return Database.currentProfileObject.nzbgetHeaders;
case LunaModule.SEARCH: throw Exception('Search does not have a headers page');
case LunaModule.SETTINGS: throw Exception('Settings does not have a headers page');
case LunaModule.WAKE_ON_LAN: throw Exception('Wake on LAN does not have a headers page');
case LunaModule.TAUTULLI: return Database.currentProfileObject.tautulliHeaders;
}
throw Exception('An unknown LunaModule was passed in.');
}
Future<void> _resetState() async {
switch(widget.module) {
case LunaModule.DASHBOARD: throw Exception('Dashboard does not have a headers page');
case LunaModule.LIDARR: return;
case LunaModule.RADARR: return context.read<RadarrState>().reset();
case LunaModule.SONARR: return context.read<SonarrState>().reset();
case LunaModule.SABNZBD: return;
case LunaModule.NZBGET: return;
case LunaModule.SEARCH: throw Exception('Search does not have a headers page');
case LunaModule.SETTINGS: throw Exception('Settings does not have a headers page');
case LunaModule.WAKE_ON_LAN: throw Exception('Wake on LAN does not have a headers page');
case LunaModule.TAUTULLI: return context.read<TautulliState>().reset();
}
throw Exception('An unknown LunaModule was passed in.');
}
}