feat: add completed state for jobs widget #421

Closed
def wants to merge 10 commits from add_complated_state_for_jobs_widget into master
4 changed files with 36 additions and 11 deletions

View File

@ -584,6 +584,7 @@
"title": "Jobs list",
"start": "Start",
"empty": "No jobs",
"completed": "Jobs completed",
"create_user": "Create user",
"delete_user": "Delete user",
"service_turn_off": "Turn off",
@ -633,4 +634,4 @@
"reset_onboarding_description": "Reset onboarding switch to show onboarding screen again",
"cubit_statuses": "Cubit loading statuses"
}
}
}

View File

@ -92,7 +92,7 @@ class JobsCubit extends Cubit<JobsState> {
await api.apply();
await servicesCubit.load();
emit(JobsStateEmpty());
emit(JobsCompleted());
}
}
}

View File

@ -9,6 +9,8 @@ class JobsStateLoading extends JobsState {}
class JobsStateEmpty extends JobsState {}
class JobsCompleted extends JobsState {}
class JobsStateWithJobs extends JobsState {
JobsStateWithJobs(this.clientJobList);
final List<ClientJob> clientJobList;

View File

@ -32,16 +32,38 @@ class JobsContent extends StatelessWidget {
late List<Widget> widgets;
final ServerInstallationState installationState =
context.read<ServerInstallationCubit>().state;
if (state is JobsStateEmpty) {
widgets = [
const SizedBox(height: 80),
Center(
child: Text(
'jobs.empty'.tr(),
style: Theme.of(context).textTheme.bodyLarge,
if (state is JobsStateEmpty || state is JobsCompleted) {
if (state is JobsStateEmpty) {
widgets = [
const SizedBox(height: 80),
Center(
child: Text(
'jobs.empty'.tr(),
style: Theme.of(context).textTheme.bodyLarge,
),
),
),
];
];
} else {
widgets = [
const SizedBox(height: 80),
Center(
child: Icon(
Icons.check,
size: 60.0,
color: Theme.of(context).colorScheme.onSurface,
),
),
const SizedBox(height: 32),
Center(
child: Text(
'jobs.completed'.tr(),
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
),
),
];
}
if (installationState is ServerInstallationFinished) {
widgets = [