cargo66/lib/presentation/screens/order_details.dart

127 lines
3.5 KiB
Dart
Raw Normal View History

2024-07-24 12:14:17 +00:00
import 'package:cargo/configs/configs.dart';
import 'package:flutter/material.dart';
2024-08-15 05:49:01 +00:00
import 'package:flutter_bloc/flutter_bloc.dart';
2024-07-24 12:14:17 +00:00
2024-08-19 06:02:02 +00:00
import '../../application/order_detail_bloc/order_detail_bloc.dart';
2024-07-24 12:14:17 +00:00
import '../../core/core.dart';
2024-08-19 06:02:02 +00:00
import '../../domain/entities/order/order.dart';
2024-07-29 07:35:53 +00:00
import '../widgets/map/clustering.dart';
2024-07-24 12:14:17 +00:00
import '../widgets/widgets.dart';
2024-08-19 06:54:43 +00:00
import 'package:flutter/services.dart';
2024-08-15 05:49:01 +00:00
class OrderDetailsScreen extends StatefulWidget {
final OrderEntity order;
2024-08-19 06:54:43 +00:00
2024-08-15 05:49:01 +00:00
const OrderDetailsScreen({super.key, required this.order});
@override
State<OrderDetailsScreen> createState() => _OrderDetailsScreenState();
}
class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
2024-08-19 06:54:43 +00:00
bool _isFullScreen = false; // Track fullscreen mode
2024-08-15 05:49:01 +00:00
@override
void initState() {
context.read<OrderDetailBloc>().add(GetRoutes(widget.order.cargoId));
super.initState();
}
2024-07-24 12:14:17 +00:00
2024-08-19 06:54:43 +00:00
void _toggleFullScreen() {
setState(() {
_isFullScreen = !_isFullScreen;
if (_isFullScreen) {
// Enter fullscreen mode
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
} else {
// Exit fullscreen mode
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
}
});
}
2024-07-24 12:14:17 +00:00
@override
Widget build(BuildContext context) {
App.init(context);
return Scaffold(
backgroundColor: AppColors.surface,
2024-08-19 06:54:43 +00:00
appBar: _isFullScreen
? null // Hide the app bar in fullscreen mode
: AppBar(
iconTheme: const IconThemeData(
color: Colors.white,
),
backgroundColor: AppColors.primary,
title: Text(
'Sargyt: ${widget.order.name}',
style: AppText.h2!.copyWith(color: Colors.white),
),
),
2024-07-24 12:14:17 +00:00
body: CustomScrollView(
slivers: [
/// map
2024-07-29 07:35:53 +00:00
SliverToBoxAdapter(
child: SizedBox(
2024-08-19 06:54:43 +00:00
height: _isFullScreen
? MediaQuery.of(context).size.height // Full screen height
: AppDimensions.normalize(130),
child: ClusteringPage(
onFullScreenToggle: _toggleFullScreen,
isFullScreen: _isFullScreen,
),
2024-07-29 07:35:53 +00:00
),
2024-07-24 12:14:17 +00:00
),
2024-08-19 06:54:43 +00:00
if (!_isFullScreen) ...[
/// info text
SliverToBoxAdapter(
child: Padding(
padding: Space.all(1, 1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Sargyt barada maglumat №${widget.order.no}',
style: AppText.b1b,
),
/// gap
Space.y!,
/// info card
InfoCard(order: widget.order),
],
),
2024-07-24 12:14:17 +00:00
),
),
2024-08-19 06:54:43 +00:00
/// current location info
SliverToBoxAdapter(
child: Padding(
padding: Space.all(1, 1),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Gatnaw yoly',
style: AppText.b1b,
),
/// gap
Space.y!,
/// location card
LocationCard(cargoId: widget.order.cargoId),
],
),
2024-07-24 12:14:17 +00:00
),
),
2024-08-19 06:54:43 +00:00
],
2024-07-24 12:14:17 +00:00
],
),
);
}
}