Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
deserveded committed Apr 19, 2024
2 parents acc6372 + 83a2a62 commit 053af02
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 105 deletions.
3 changes: 2 additions & 1 deletion lib/feature/data/datasources/order_remote_data_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ class OrderRemoteDataSourceImpl implements OrderRemoteDataSource {

@override
Future<void> setOrderIsDelivered(int id, bool isDelivered) async {

final List<Map<String, dynamic>> data = await supabaseClient
.from("Orders")
.update({'is_delivered': isDelivered})
.update({'is_delivered': isDelivered, 'delivery_date': DateTime.now()})
.eq('order_number', id)
.select();
print('data --> $data');
Expand Down
3 changes: 3 additions & 0 deletions lib/feature/data/models/order_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class OrderModel extends OrderEntity {
required super.clientName,
required super.orderDate,
required super.neadToCall,
required super.paymentMethod,
});

factory OrderModel.fromJson(Map<String, dynamic> map) {
Expand All @@ -22,6 +23,7 @@ class OrderModel extends OrderEntity {
clientName: map['client_name'] as String,
orderDate: DateTime.parse(map['order_date'] as String),
neadToCall: map['nead_to_call'] as bool,
paymentMethod: map['payment_method'] as String,
);
}

Expand All @@ -35,6 +37,7 @@ class OrderModel extends OrderEntity {
'clientName': clientName,
'orderDate': orderDate.toIso8601String(),
'neadToCall': neadToCall,
'paymentMethod': paymentMethod,
};
}
}
24 changes: 14 additions & 10 deletions lib/feature/domain/entities/order_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ class OrderEntity extends Equatable {
final String clientName;
final DateTime orderDate;
final bool neadToCall;
final String paymentMethod;

const OrderEntity(
{required this.id,
required this.orderNumber,
required this.address,
required this.isDelivered,
required this.clientPhone,
required this.clientName,
required this.orderDate,
required this.neadToCall});
const OrderEntity({
required this.id,
required this.orderNumber,
required this.address,
required this.isDelivered,
required this.clientPhone,
required this.clientName,
required this.orderDate,
required this.neadToCall,
required this.paymentMethod,
});

@override
get props => [
Expand All @@ -29,6 +32,7 @@ class OrderEntity extends Equatable {
clientPhone,
clientName,
orderDate,
neadToCall
neadToCall,
paymentMethod,
];
}
193 changes: 99 additions & 94 deletions lib/feature/presentation/pages/order_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
return Scaffold(
appBar: AppBar(
centerTitle: true,
shadowColor: Colors.white,

surfaceTintColor: Colors.white,
title: Text(
"Номер заказа | $orderId",
style: const TextStyle(
Expand Down Expand Up @@ -329,8 +332,8 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
const SizedBox.square(
dimension: 10,
),
const Text('Яндекс чек',
style: TextStyle(
Text(order.paymentMethod,
style: const TextStyle(
color: Colors.black,
fontSize: 16,
fontFamily: 'Nunito',
Expand Down Expand Up @@ -383,95 +386,6 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
},
),
),
const Divider(color: Color(0xFFAFA8A1)),
BlocBuilder<OrdersCostCubit, OrdersCostState>(
builder: (context, state) {
if (state is OrdersCostSuccess) {
return Text(
"Итоговая стоимость ${state.costs[orderId]!.toStringAsFixed(2)} ₽ ",
style: const TextStyle(
color: Colors.black,
fontSize: 17,
fontFamily: 'Nunito',
fontWeight: FontWeight.w400,
),
);
} else if (state is OrdersCostFailure) {
return Text(state.message);
} else {
return const Text('Loading...');
}
},
),
BlocBuilder<OrdersCostCubit, OrdersCostState>(
builder: (context, state) {
if (state is OrdersCostSuccess) {
return Text(
"Процент курьера ${state.costsForRecent[orderId]!.toStringAsFixed(2)} ₽ (40%)",
style: const TextStyle(
color: Colors.black,
fontSize: 17,
fontFamily: 'Nunito',
fontWeight: FontWeight.w400,
),
);
} else if (state is OrdersCostFailure) {
return Text(state.message);
} else {
return const Text('Loading...');
}
},
),
isDelivered
? ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(60),
foregroundColor: Colors.black,
backgroundColor: Colors.black,
surfaceTintColor: Colors.black,
),
onPressed: () {},
child: const Text(
'Заказ доставлен',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Nunito',
fontWeight: FontWeight.w600,
height: 0.07,
letterSpacing: 0.09,
),
),
)
: Align(
alignment: Alignment.bottomLeft,
child: SwipeableButtonView(
buttonText: "Доставлен",
buttontextstyle: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Nunito',
fontWeight: FontWeight.w600,
height: 0.07,
letterSpacing: 0.09,
),
buttonWidget: Container(
child: const Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey,
),
),
activeColor: const Color(0xFF78C4A4),
isFinished: isFinished,
onWaitingProcess: () {
Future.delayed(Duration(seconds: 2), () {
context
.read<SetDeliveredCubit>()
.setOrderIsDelivered(orderId, true);
});
},
onFinish: () async {}),
),
BlocListener<SetDeliveredCubit, SetDeliveredState>(
listener: (context, state) {
if (state is SetDeliveredLoaded) {
Expand All @@ -498,9 +412,100 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
bottomNavigationBar: Padding(
padding: EdgeInsets.all(20),
child: Container(
height: 60,
color: Colors.amber,
),
height: 125,
child: Column(
children: <Widget>[
const Divider(color: Color(0xFFAFA8A1)),
BlocBuilder<OrdersCostCubit, OrdersCostState>(
builder: (context, state) {
if (state is OrdersCostSuccess) {
return Text(
"Итоговая стоимость ${state.costs[orderId]!.toStringAsFixed(2)} ₽ ",
style: const TextStyle(
color: Colors.black,
fontSize: 17,
fontFamily: 'Nunito',
fontWeight: FontWeight.w400,
),
);
} else if (state is OrdersCostFailure) {
return Text(state.message);
} else {
return const Text('Loading...');
}
},
),
BlocBuilder<OrdersCostCubit, OrdersCostState>(
builder: (context, state) {
if (state is OrdersCostSuccess) {
return Text(
"Процент курьера ${state.costsForRecent[orderId]!.toStringAsFixed(2)} ₽ (40%)",
style: const TextStyle(
color: Colors.black,
fontSize: 17,
fontFamily: 'Nunito',
fontWeight: FontWeight.w400,
),
);
} else if (state is OrdersCostFailure) {
return Text(state.message);
} else {
return const Text('Loading...');
}
},
),
isDelivered
? ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const Size.fromHeight(60),
foregroundColor: Colors.black,
backgroundColor: Colors.black,
surfaceTintColor: Colors.black,
),
onPressed: () {},
child: const Text(
'Заказ доставлен',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Nunito',
fontWeight: FontWeight.w600,
height: 0.07,
letterSpacing: 0.09,
),
),
)
: Align(
alignment: Alignment.bottomLeft,
child: SwipeableButtonView(
buttonText: "Доставлен",
buttontextstyle: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Nunito',
fontWeight: FontWeight.w600,
height: 0.07,
letterSpacing: 0.09,
),
buttonWidget: Container(
child: const Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey,
),
),
activeColor: const Color(0xFF78C4A4),
isFinished: isFinished,
onWaitingProcess: () {
Future.delayed(Duration(seconds: 2), () {
context
.read<SetDeliveredCubit>()
.setOrderIsDelivered(orderId, true);
});
},
onFinish: () async {}),
),
],
)),
),
);
}
Expand Down

0 comments on commit 053af02

Please sign in to comment.