Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: TimelineView zoom #146

Merged
merged 12 commits into from
Aug 28, 2023
9 changes: 4 additions & 5 deletions lib/api/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,22 @@ extension EventsExtension on API {
}

static Future<Iterable<Event>> _getEvents(Map data) async {
final server = data['server'];
final server = data['server'] as Server;
if (!server.online) {
debugPrint('Can not get events of an offline server: $server');
return [];
}

final limit = data['limit'] as int;

DevHttpOverrides.configureCertificates();

assert(server.serverUUID != null && server.cookie != null);
final response = await http.get(
Uri.https(
'${Uri.encodeComponent(server.login)}:${Uri.encodeComponent(server.password)}@${server.ip}:${server.port}',
'/events/',
{
'XML': '1',
'limit': '${data['limit']}',
},
{'XML': '1', 'limit': '$limit'},
),
headers: {
'Cookie': server.cookie!,
Expand Down
10 changes: 9 additions & 1 deletion lib/providers/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,13 @@ class SettingsProvider extends ChangeNotifier {

enum NotificationClickAction {
showFullscreenCamera,
showEventsScreen,
showEventsScreen;

IconData get icon {
return switch (this) {
NotificationClickAction.showEventsScreen =>
Icons.featured_play_list_outlined,
NotificationClickAction.showFullscreenCamera => Icons.screenshot_monitor,
};
}
}
33 changes: 29 additions & 4 deletions lib/widgets/downloads_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,16 @@ class DownloadProgressIndicator extends StatelessWidget {
const DownloadProgressIndicator({
super.key,
required this.progress,
this.color,
});

final DownloadProgress progress;

/// The color of the indicator.
///
/// If not provided, the primary color is used instead.
final Color? color;

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
Expand All @@ -365,13 +371,14 @@ class DownloadProgressIndicator extends StatelessWidget {
child: CircularProgressIndicator(
value: progress,
strokeWidth: 2.0,
color: color,
),
),
Center(
child: Icon(
Icons.download,
size: 14.0,
color: theme.colorScheme.primary,
color: color ?? theme.colorScheme.primary,
),
),
]);
Expand All @@ -385,7 +392,18 @@ class DownloadProgressIndicator extends StatelessWidget {
class DownloadIndicator extends StatelessWidget {
final Event event;

const DownloadIndicator({super.key, required this.event});
/// Whether to highlight the indicator with a white color and an outline border
final bool highlight;

/// Whether the indicator is small
final bool small;

const DownloadIndicator({
super.key,
required this.event,
this.highlight = false,
this.small = false,
});

@override
Widget build(BuildContext context) {
Expand All @@ -400,6 +418,7 @@ class DownloadIndicator extends StatelessWidget {
return Icon(
Icons.warning,
color: theme.extension<UnityColors>()!.warningColor,
size: small ? 18.0 : null,
);
}

Expand All @@ -411,6 +430,7 @@ class DownloadIndicator extends StatelessWidget {
context.read<HomeProvider>().toDownloads(event.id, context);
},
tooltip: loc.seeInDownloads,
iconSize: small ? 18.0 : null,
icon: Icon(
Icons.download_done,
color: theme.extension<UnityColors>()!.successColor,
Expand All @@ -422,6 +442,7 @@ class DownloadIndicator extends StatelessWidget {
return DownloadProgressIndicator(
progress: downloads.downloading[downloads.downloading.keys
.firstWhere((e) => e.id == event.id)]!,
color: highlight ? Colors.amber : null,
);
}

Expand All @@ -430,8 +451,12 @@ class DownloadIndicator extends StatelessWidget {
padding: EdgeInsets.zero,
tooltip: loc.download,
onPressed: () => downloads.download(event),
iconSize: 22.0,
icon: const Icon(Icons.download),
iconSize: small ? 18.0 : 22.0,
icon: Icon(
Icons.download,
color: highlight ? Colors.white : null,
shadows: highlight ? outlinedText() : null,
),
);
}
}(),
Expand Down
125 changes: 63 additions & 62 deletions lib/widgets/events/event_player_desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,72 +340,73 @@ class _EventPlayerDesktopState extends State<EventPlayerDesktop> {
]),
]),
),
CollapsableSidebar(
left: false,
builder: (context, collapsed, collapseButton) {
if (collapsed) {
return collapseButton;
}
return Column(children: [
Row(children: [
const SizedBox(width: 16.0),
Expanded(
child: Text(
loc.nextEvents,
style: theme.textTheme.bodySmall,
if (widget.upcomingEvents.isNotEmpty)
CollapsableSidebar(
left: false,
builder: (context, collapsed, collapseButton) {
if (collapsed) {
return collapseButton;
}
return Column(children: [
Row(children: [
const SizedBox(width: 16.0),
Expanded(
child: Text(
loc.nextEvents,
style: theme.textTheme.bodySmall,
),
),
),
Align(
alignment: AlignmentDirectional.topEnd,
child: collapseButton,
),
]),
Expanded(
child: ListView(
padding: const EdgeInsetsDirectional.only(
end: 16.0,
start: 16.0,
bottom: 12.0,
Align(
alignment: AlignmentDirectional.topEnd,
child: collapseButton,
),
children: [
// Text(
// '${currentEvent.deviceName} (${currentEvent.server.name})',
// style: const TextStyle(
// fontWeight: FontWeight.bold,
// ),
// maxLines: 1,
// ),
// Text(
// settings.formatDate(currentEvent.published),
// style: const TextStyle(fontSize: 12.0),
// ),
// Text(
// '(${currentEvent.priority.locale(context)})'
// ' ${currentEvent.type.locale(context)}',
// ),
EventTile(
key: ValueKey(currentEvent),
event: currentEvent,
]),
Expanded(
child: ListView(
padding: const EdgeInsetsDirectional.only(
end: 16.0,
start: 16.0,
bottom: 12.0,
),
...widget.upcomingEvents.map((event) {
if (event == currentEvent) {
return const SizedBox.shrink();
}
return Padding(
padding:
const EdgeInsetsDirectional.only(top: 6.0),
child: EventTile(
event: event,
onPlay: () => setEvent(event),
),
);
}),
],
children: [
// Text(
// '${currentEvent.deviceName} (${currentEvent.server.name})',
// style: const TextStyle(
// fontWeight: FontWeight.bold,
// ),
// maxLines: 1,
// ),
// Text(
// settings.formatDate(currentEvent.published),
// style: const TextStyle(fontSize: 12.0),
// ),
// Text(
// '(${currentEvent.priority.locale(context)})'
// ' ${currentEvent.type.locale(context)}',
// ),
EventTile(
key: ValueKey(currentEvent),
event: currentEvent,
),
...widget.upcomingEvents.map((event) {
if (event == currentEvent) {
return const SizedBox.shrink();
}
return Padding(
padding: const EdgeInsetsDirectional.only(
top: 6.0),
child: EventTile(
event: event,
onPlay: () => setEvent(event),
),
);
}),
],
),
),
),
]);
},
),
]);
},
),
]),
),
]),
Expand Down
Loading