return ProxmoxStreamBuilder<PveTaskLogBloc, PveTaskLogState>(
bloc: bloc,
builder: (context, state) {
- if (state.tasks != null) {
- return SafeArea(
- child: Scaffold(
- key: _scaffoldKey,
- appBar: AppBar(
- leading: IconButton(
- icon: const Icon(Icons.close),
- onPressed: () => Navigator.of(context).pop(),
- ),
- actions: <Widget>[
- IconButton(
- icon: const Icon(Icons.more_vert),
- onPressed: () =>
- _scaffoldKey.currentState?.openEndDrawer(),
- )
- ],
+ return SafeArea(
+ child: Scaffold(
+ key: _scaffoldKey,
+ appBar: AppBar(
+ leading: IconButton(
+ icon: const Icon(Icons.close),
+ onPressed: () => Navigator.of(context).pop(),
),
- endDrawer: Drawer(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(16.0, 20.0, 16.0, 0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- 'Filters',
- style: Theme.of(context).textTheme.headlineSmall,
- ),
- const SizedBox(
- height: 20,
- ),
- TextFormField(
- decoration: const InputDecoration(
- labelText: 'by user',
- filled: true,
- prefixIcon: Icon(Icons.person)),
- onChanged: (newValue) {
- bloc.events.add(FilterTasksByUser(newValue));
- bloc.events.add(LoadTasks());
- },
- controller: _userFilterController,
- ),
- const SizedBox(
- height: 20,
- ),
- TextFormField(
- decoration: const InputDecoration(
- labelText: 'by type',
- filled: true,
- prefixIcon: Icon(Icons.description)),
- onChanged: (newValue) {
- bloc.events.add(FilterTasksByType(newValue));
- bloc.events.add(LoadTasks());
- },
- controller: _typeFilterController,
- ),
- const SizedBox(
- height: 20,
- ),
- DropdownButtonFormField<String>(
- decoration:
- const InputDecoration(labelText: 'Source'),
- value: state.source,
- icon: const Icon(Icons.arrow_downward),
- iconSize: 24,
- elevation: 16,
- onChanged: (String? newValue) {
- bloc.events.add(FilterTasksBySource(newValue));
- bloc.events.add(LoadTasks());
- },
- items: <String>[
- 'all',
- 'active',
- 'archive',
- ].map<DropdownMenuItem<String>>((String value) {
- return DropdownMenuItem<String>(
- value: value,
- child: Container(child: Text(value)),
- );
- }).toList(),
- ),
- const SizedBox(
- height: 20,
+ actions: <Widget>[
+ IconButton(
+ icon: const Icon(Icons.more_vert),
+ onPressed: () => _scaffoldKey.currentState?.openEndDrawer(),
+ )
+ ],
+ ),
+ endDrawer: Drawer(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(16.0, 20.0, 16.0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: <Widget>[
+ Text(
+ 'Filters',
+ style: Theme.of(context).textTheme.headlineSmall,
+ ),
+ const SizedBox(
+ height: 20,
+ ),
+ TextFormField(
+ decoration: const InputDecoration(
+ labelText: 'by user',
+ filled: true,
+ prefixIcon: Icon(Icons.person)),
+ onChanged: (newValue) {
+ bloc.events.add(FilterTasksByUser(newValue));
+ bloc.events.add(LoadTasks());
+ },
+ controller: _userFilterController,
+ ),
+ const SizedBox(
+ height: 20,
+ ),
+ TextFormField(
+ decoration: const InputDecoration(
+ labelText: 'by type',
+ filled: true,
+ prefixIcon: Icon(Icons.description)),
+ onChanged: (newValue) {
+ bloc.events.add(FilterTasksByType(newValue));
+ bloc.events.add(LoadTasks());
+ },
+ controller: _typeFilterController,
+ ),
+ const SizedBox(
+ height: 20,
+ ),
+ DropdownButtonFormField<String>(
+ decoration: const InputDecoration(labelText: 'Source'),
+ value: state.source,
+ icon: const Icon(Icons.arrow_downward),
+ iconSize: 24,
+ elevation: 16,
+ onChanged: (String? newValue) {
+ bloc.events.add(FilterTasksBySource(newValue));
+ bloc.events.add(LoadTasks());
+ },
+ items: <String>[
+ 'all',
+ 'active',
+ 'archive',
+ ].map<DropdownMenuItem<String>>((String value) {
+ return DropdownMenuItem<String>(
+ value: value,
+ child: Container(child: Text(value)),
+ );
+ }).toList(),
+ ),
+ const SizedBox(
+ height: 20,
+ ),
+ FormField(
+ builder: (FormFieldState<bool> formFieldState) => Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: <Widget>[
+ const Text("Only errors"),
+ Checkbox(
+ value: state.onlyErrors,
+ onChanged: (value) {
+ formFieldState.didChange(value);
+ bloc.events.add(FilterTasksByError());
+ bloc.events.add(LoadTasks());
+ },
+ ),
+ ],
),
- FormField(
- builder: (FormFieldState<bool> formFieldState) => Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- const Text("Only errors"),
- Checkbox(
- value: state.onlyErrors,
- onChanged: (value) {
- formFieldState.didChange(value);
- bloc.events.add(FilterTasksByError());
- bloc.events.add(LoadTasks());
- },
- ),
- ],
- ),
- )
- ],
- ),
+ )
+ ],
),
),
- body: NotificationListener<ScrollNotification>(
- onNotification: (ScrollNotification scrollInfo) {
- if (scrollInfo.metrics.pixels >=
- (0.8 * scrollInfo.metrics.maxScrollExtent)) {
- if (!state.isLoading) {
- bloc.events.add(LoadMoreTasks());
- }
+ ),
+ body: NotificationListener<ScrollNotification>(
+ onNotification: (ScrollNotification scrollInfo) {
+ if (scrollInfo.metrics.pixels >=
+ (0.8 * scrollInfo.metrics.maxScrollExtent)) {
+ if (!state.isLoading) {
+ bloc.events.add(LoadMoreTasks());
}
- return false;
- },
- child: state.tasks.isNotEmpty
- ? ListView.builder(
- itemCount: state.tasks.length,
- itemBuilder: (context, index) => PveTaskExpansionTile(
- task: state.tasks[index],
- ),
- )
- : const Center(
- child: Text("No tasks found"),
+ }
+ return false;
+ },
+ child: state.tasks.isNotEmpty
+ ? ListView.builder(
+ itemCount: state.tasks.length,
+ itemBuilder: (context, index) => PveTaskExpansionTile(
+ task: state.tasks[index],
),
- ),
+ )
+ : const Center(
+ child: Text("No tasks found"),
+ ),
),
- );
- }
+ ),
+ );
return Container();
});
indicatorColor = Colors.red;
statusChipColor = Colors.red.shade100;
}
- return Container(
+ return SizedBox(
height: MediaQuery.of(context).size.height * 0.5,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,