103 lines
3.5 KiB
Dart
103 lines
3.5 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../domain/chat_shells.dart';
|
|
import 'chat_background_tasks_controller.dart';
|
|
import 'chat_background_tasks_panel.dart';
|
|
import 'chat_task_presentation.dart';
|
|
|
|
/// A task inspector needs a reading surface, rather than alert-sized content.
|
|
class ChatBackgroundTasksDialog extends StatelessWidget {
|
|
const ChatBackgroundTasksDialog({
|
|
super.key,
|
|
required this.controller,
|
|
required this.onClose,
|
|
});
|
|
final ChatBackgroundTasksController controller;
|
|
final VoidCallback onClose;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: controller,
|
|
builder: (context, _) => _dialog(context),
|
|
);
|
|
|
|
Widget _dialog(BuildContext context) {
|
|
final cupertino = taskCupertino(context);
|
|
final title = (controller.automationStatus.count ?? 0) > 0
|
|
? (controller.running.isEmpty ? 'Automations' : 'Tasks and automations')
|
|
: backgroundTasksTitle;
|
|
final panel = Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: ChatBackgroundTasksPanel(controller: controller),
|
|
);
|
|
if (cupertino) {
|
|
return Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: FractionallySizedBox(
|
|
heightFactor: 0.88,
|
|
child: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 840),
|
|
child: CupertinoPageScaffold(
|
|
backgroundColor: CupertinoColors.systemGroupedBackground
|
|
.resolveFrom(context),
|
|
navigationBar: CupertinoNavigationBar(
|
|
automaticallyImplyLeading: false,
|
|
leading: const Icon(CupertinoIcons.square_stack_3d_up),
|
|
middle: Text(title),
|
|
trailing: CupertinoButton(
|
|
padding: EdgeInsets.zero,
|
|
onPressed: onClose,
|
|
child: const Text('Done'),
|
|
),
|
|
),
|
|
child: SafeArea(child: SingleChildScrollView(child: panel)),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return Dialog(
|
|
constraints: const BoxConstraints(maxWidth: 840),
|
|
insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24),
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxHeight: MediaQuery.sizeOf(context).height * 0.88,
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(24, 20, 12, 0),
|
|
child: Wrap(
|
|
alignment: WrapAlignment.spaceBetween,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
spacing: 12,
|
|
runSpacing: 8,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.layers_outlined),
|
|
const SizedBox(width: 12),
|
|
Flexible(
|
|
child: Text(
|
|
title,
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
TextButton(onPressed: onClose, child: const Text('Done')),
|
|
],
|
|
),
|
|
),
|
|
Flexible(child: SingleChildScrollView(child: panel)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|