Files
lunasea/lib/modules/sonarr/routes/missing/widgets/missing_tile.dart
Jagandeep Brar 139c9a0cd3 (ui): Removed all deprecated UI elements, added scroll-back support to entire UI, clean-up codebase (#396)
* 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
2021-04-01 22:06:07 -05:00

172 lines
5.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:lunasea/core.dart';
import 'package:lunasea/modules/sonarr.dart';
class SonarrMissingTile extends StatefulWidget {
final SonarrMissingRecord record;
SonarrMissingTile({
Key key,
@required this.record,
}) : super(key: key);
@override
State<SonarrMissingTile> createState() => _State();
}
class _State extends State<SonarrMissingTile> {
final double _height = 90.0;
final double _width = 60.0;
final double _padding = 8.0;
@override
Widget build(BuildContext context) => Selector<SonarrState, Future<SonarrMissing>>(
selector: (_, state) => state.missing,
builder: (context, series, _) => LunaCard(
context: context,
child: InkWell(
child: Row(
children: [
_poster,
Expanded(child: _information),
_trailing,
],
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
),
borderRadius: BorderRadius.circular(LunaUI.BORDER_RADIUS),
onTap: _tileOnTap,
onLongPress: _tileOnLongPress,
),
decoration: LunaCardDecoration(
uri: Provider.of<SonarrState>(context, listen: false).getBannerURL(widget.record.seriesId),
headers: Provider.of<SonarrState>(context, listen: false).headers,
),
),
);
Widget get _poster => LunaNetworkImage(
url: Provider.of<SonarrState>(context, listen: false).getPosterURL(widget.record.seriesId),
placeholderAsset: 'assets/images/blanks/video.png',
height: _height,
width: _width,
headers: Provider.of<SonarrState>(context, listen: false).headers.cast<String, String>(),
);
Widget get _information => Padding(
child: Container(
child: Column(
children: [
LunaText.title(text: widget.record.series.title, darken: !widget.record.monitored, maxLines: 1),
_subtitleOne,
_subtitleTwo,
_subtitleThree,
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
),
height: (_height-(_padding*2)),
),
padding: EdgeInsets.all(_padding),
);
Widget get _trailing => Container(
child: Padding(
child: LunaIconButton(
icon: Icons.search,
onPressed: _trailingOnPressed,
onLongPress: _trailingOnLongPress,
),
padding: EdgeInsets.only(right: 12.0),
),
height: _height,
);
Widget get _subtitleOne => RichText(
text: TextSpan(
style: TextStyle(
fontSize: LunaUI.FONT_SIZE_SUBTITLE,
color: widget.record.monitored ? Colors.white70 : Colors.white30,
),
children: [
TextSpan(text: widget.record.seasonNumber == 0 ? 'Specials ' : 'Season ${widget.record.seasonNumber} '),
TextSpan(text: LunaUI.TEXT_EMDASH),
TextSpan(text: ' Episode ${widget.record.episodeNumber}'),
],
),
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
);
Widget get _subtitleTwo => RichText(
text: TextSpan(
style: TextStyle(
fontSize: LunaUI.FONT_SIZE_SUBTITLE,
color: widget.record.monitored ? Colors.white70 : Colors.white30,
),
children: [
TextSpan(
style: TextStyle(
fontStyle: FontStyle.italic,
),
text: widget.record.title ?? 'Unknown Title',
),
],
),
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
);
Widget get _subtitleThree => RichText(
text: TextSpan(
style: TextStyle(
fontSize: LunaUI.FONT_SIZE_SUBTITLE,
color: LunaColours.red,
fontWeight: LunaUI.FONT_WEIGHT_BOLD,
),
children: [
TextSpan(text: widget.record.airDateUtc == null
? 'Aired'
: 'Aired ${widget.record.airDateUtc?.toLocal()?.lunaAge}'),
],
),
overflow: TextOverflow.fade,
softWrap: false,
maxLines: 1,
);
Future<void> _tileOnTap() async => SonarrSeasonDetailsRouter().navigateTo(
context,
seriesId: widget.record.seriesId,
seasonNumber: widget.record.seasonNumber,
);
Future<void> _tileOnLongPress() async => SonarrSeriesDetailsRouter().navigateTo(
context,
seriesId: widget.record.seriesId,
);
Future<void> _trailingOnPressed() async {
Provider.of<SonarrState>(context, listen: false).api.command.episodeSearch(episodeIds: [widget.record.id])
.then((_) => showLunaSuccessSnackBar(
title: 'Searching for Episode...',
message: widget.record.title,
))
.catchError((error, stack) {
LunaLogger().error('Failed to search for episode: ${widget.record.id}', error, stack);
showLunaErrorSnackBar(
title: 'Failed to Search',
error: error,
);
});
}
Future<void> _trailingOnLongPress() async => SonarrReleasesRouter().navigateTo(
context,
episodeId: widget.record.id,
);
}