|
|
|
|
@ -9,9 +9,7 @@ import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
|
|
|
|
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
|
|
|
|
|
|
|
|
|
class AlertsListPage extends StatefulWidget {
|
|
|
|
|
final bool fromBottomBar;
|
|
|
|
|
|
|
|
|
|
const AlertsListPage({Key? key, this.fromBottomBar = false}) : super(key: key);
|
|
|
|
|
const AlertsListPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<AlertsListPage> createState() => _AlertsListPageState();
|
|
|
|
|
@ -25,34 +23,31 @@ class _AlertsListPageState extends State<AlertsListPage> {
|
|
|
|
|
_provider = Provider.of<AlertProvider>(context);
|
|
|
|
|
if (_provider!.items == null && !_provider!.isLoading) {
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
_provider!.reset();
|
|
|
|
|
_provider!.getAlerts();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: DefaultAppBar(title: "Alerts", showBackButton: !widget.fromBottomBar),
|
|
|
|
|
body: Consumer<AlertProvider>(builder: (context, snapshot, _) {
|
|
|
|
|
final list = snapshot.items ?? [];
|
|
|
|
|
if (list.isEmpty && !snapshot.isLoading) {
|
|
|
|
|
return NoDataFound(message: context.translation.noDataFound).center;
|
|
|
|
|
}
|
|
|
|
|
return LazyLoading(
|
|
|
|
|
nextPage: snapshot.nextPage,
|
|
|
|
|
onLazyLoad: () async {
|
|
|
|
|
await snapshot.getAlerts();
|
|
|
|
|
return Consumer<AlertProvider>(builder: (context, snapshot, _) {
|
|
|
|
|
final list = snapshot.items ?? [];
|
|
|
|
|
if (list.isEmpty && !snapshot.isLoading) {
|
|
|
|
|
return NoDataFound(message: context.translation.noDataFound).center;
|
|
|
|
|
}
|
|
|
|
|
return LazyLoading(
|
|
|
|
|
nextPage: snapshot.nextPage,
|
|
|
|
|
onLazyLoad: () async {
|
|
|
|
|
await snapshot.getAlerts();
|
|
|
|
|
},
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
if (index >= list.length) return const SizedBox();
|
|
|
|
|
return AlertItemView(alert: list[index]);
|
|
|
|
|
},
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
if (index >= list.length) return const SizedBox();
|
|
|
|
|
return AlertItemView(alert: list[index]);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => const SizedBox(height: 12),
|
|
|
|
|
itemCount: list.length,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
separatorBuilder: (cxt, index) => const SizedBox(height: 12),
|
|
|
|
|
itemCount: list.length,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|