mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
refactor(ui): Extract ServerJobsListTitle
This commit is contained in:
parent
529a9e515a
commit
791e895dc7
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/logic/models/json/server_job.dart';
|
||||
|
||||
|
||||
IconData getJobIcon(final JobStatusEnum status) {
|
||||
switch (status) {
|
||||
case JobStatusEnum.created:
|
||||
|
|
|
@ -123,26 +123,8 @@ class JobsContent extends StatelessWidget {
|
|||
const Divider(height: 0),
|
||||
const Gap(16),
|
||||
if (serverJobs.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'jobs.server_jobs'.tr(),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: hasRemovableJobs
|
||||
? () => context
|
||||
.read<ServerJobsBloc>()
|
||||
.add(RemoveAllFinishedJobs())
|
||||
: null,
|
||||
icon: const Icon(Icons.clear_all),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
],
|
||||
),
|
||||
_ServerJobsListTitle(
|
||||
hasRemovableJobs: hasRemovableJobs,
|
||||
),
|
||||
...serverJobs
|
||||
.whereNot((final job) => job.uid == state.rebuildJobUid)
|
||||
|
@ -361,3 +343,34 @@ class _ServerJobStatusCardInClientJobs extends StatelessWidget {
|
|||
],
|
||||
);
|
||||
}
|
||||
|
||||
class _ServerJobsListTitle extends StatelessWidget {
|
||||
const _ServerJobsListTitle({
|
||||
required this.hasRemovableJobs,
|
||||
});
|
||||
|
||||
final bool hasRemovableJobs;
|
||||
|
||||
@override
|
||||
Widget build(final BuildContext context) => Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'jobs.server_jobs'.tr(),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: hasRemovableJobs
|
||||
? () => context
|
||||
.read<ServerJobsBloc>()
|
||||
.add(RemoveAllFinishedJobs())
|
||||
: null,
|
||||
icon: const Icon(Icons.clear_all),
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue