2022-12-27 03:19:49 +00:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-12-27 05:29:50 +00:00
|
|
|
import 'package:selfprivacy/logic/courierscubit.dart';
|
2022-12-27 06:23:01 +00:00
|
|
|
import 'package:selfprivacy/logic/courierformcubit.dart';
|
2022-12-27 03:19:49 +00:00
|
|
|
import 'package:selfprivacy/models/courier.dart';
|
2022-12-27 06:23:01 +00:00
|
|
|
import 'package:selfprivacy/ui/bottomsheet.dart';
|
|
|
|
import 'package:selfprivacy/ui/button.dart';
|
2022-12-27 03:19:49 +00:00
|
|
|
|
|
|
|
part 'courier.dart';
|
2022-12-27 06:23:01 +00:00
|
|
|
part 'courierdetails.dart';
|
2022-12-27 03:19:49 +00:00
|
|
|
|
|
|
|
class CouriersPage extends StatelessWidget {
|
|
|
|
const CouriersPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final Widget child = BlocBuilder<CouriersCubit, CouriersState>(
|
|
|
|
builder: (final BuildContext context, final CouriersState state) {
|
|
|
|
final List<Courier> couriers = state.couriers;
|
|
|
|
|
|
|
|
if (couriers.isEmpty) {
|
|
|
|
if (state.isLoading) {
|
|
|
|
return const Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return RefreshIndicator(
|
|
|
|
onRefresh: () async {
|
|
|
|
context.read<CouriersCubit>().refresh();
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
|
|
|
child: Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: const BoxConstraints(
|
|
|
|
minHeight: 40,
|
|
|
|
minWidth: double.infinity,
|
|
|
|
),
|
|
|
|
child: OutlinedButton(
|
|
|
|
onPressed: () {
|
|
|
|
context.read<CouriersCubit>().refresh();
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
'Обновить',
|
|
|
|
style: Theme.of(context).textTheme.button?.copyWith(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RefreshIndicator(
|
|
|
|
onRefresh: () async {
|
|
|
|
context.read<CouriersCubit>().refresh();
|
|
|
|
},
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: couriers.length,
|
|
|
|
itemBuilder: (final BuildContext context, final int index) =>
|
|
|
|
_Courier(
|
|
|
|
courier: couriers[index],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: PreferredSize(
|
|
|
|
preferredSize: const Size.fromHeight(52),
|
|
|
|
child: AppBar(
|
|
|
|
title: const Padding(
|
|
|
|
padding: EdgeInsets.only(top: 4.0),
|
2022-12-27 05:47:58 +00:00
|
|
|
child: Text('Курьеры'),
|
2022-12-27 03:19:49 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: child,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|