Compare commits
No commits in common. "c8f8d2ec9d62085251599c1d6c590f5ffc9f459c" and "e1825fe86f68828ab4e5f892e581bb616d7a9a4b" have entirely different histories.
c8f8d2ec9d
...
e1825fe86f
@ -1,21 +1,17 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:enaklo_pos/core/constants/variables.dart';
|
import 'package:enaklo_pos/core/constants/variables.dart';
|
||||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
import 'package:enaklo_pos/data/models/response/order_remote_datasource.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/payment_method_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/payment_method_response_model.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/summary_response_model.dart';
|
import 'package:enaklo_pos/data/models/response/summary_response_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
import 'package:enaklo_pos/presentation/home/models/order_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_request.dart';
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
class OrderRemoteDatasource {
|
class OrderRemoteDatasource {
|
||||||
final Dio dio = DioClient.instance;
|
|
||||||
|
|
||||||
//save order to remote server
|
//save order to remote server
|
||||||
Future<bool> saveOrder(OrderModel orderModel) async {
|
Future<bool> saveOrder(OrderModel orderModel) async {
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
final authData = await AuthLocalDataSource().getAuthData();
|
||||||
@ -32,11 +28,11 @@ class OrderRemoteDatasource {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
print("📥 HTTP Status Code: ${response.statusCode}");
|
print("📥 HTTP Status Code: ${response.statusCode}");
|
||||||
print("📥 Response Body: ${response.body}");
|
print("📥 Response Body: ${response.body}");
|
||||||
print("📥 Response Headers: ${response.headers}");
|
print("📥 Response Headers: ${response.headers}");
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print("âś… API call successful - Order saved to server");
|
print("âś… API call successful - Order saved to server");
|
||||||
return true;
|
return true;
|
||||||
@ -73,8 +69,7 @@ class OrderRemoteDatasource {
|
|||||||
print("âś… getOrderByRangeDate API call successful");
|
print("âś… getOrderByRangeDate API call successful");
|
||||||
return Right(OrderResponseModel.fromJson(response.body));
|
return Right(OrderResponseModel.fromJson(response.body));
|
||||||
} else {
|
} else {
|
||||||
print(
|
print("❌ getOrderByRangeDate API call failed - Status: ${response.statusCode}");
|
||||||
"❌ getOrderByRangeDate API call failed - Status: ${response.statusCode}");
|
|
||||||
print("❌ Error Response: ${response.body}");
|
print("❌ Error Response: ${response.body}");
|
||||||
return const Left("Failed Load Data");
|
return const Left("Failed Load Data");
|
||||||
}
|
}
|
||||||
@ -107,8 +102,7 @@ class OrderRemoteDatasource {
|
|||||||
print("âś… getSummaryByRangeDate API call successful");
|
print("âś… getSummaryByRangeDate API call successful");
|
||||||
return Right(SummaryResponseModel.fromJson(response.body));
|
return Right(SummaryResponseModel.fromJson(response.body));
|
||||||
} else {
|
} else {
|
||||||
print(
|
print("❌ getSummaryByRangeDate API call failed - Status: ${response.statusCode}");
|
||||||
"❌ getSummaryByRangeDate API call failed - Status: ${response.statusCode}");
|
|
||||||
print("❌ Error Response: ${response.body}");
|
print("❌ Error Response: ${response.body}");
|
||||||
return const Left("Failed Load Data");
|
return const Left("Failed Load Data");
|
||||||
}
|
}
|
||||||
@ -118,8 +112,7 @@ class OrderRemoteDatasource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Either<String, PaymentMethodResponseModel>>
|
Future<Either<String, PaymentMethodResponseModel>> getPaymentMethodByRangeDate(
|
||||||
getPaymentMethodByRangeDate(
|
|
||||||
String startDate,
|
String startDate,
|
||||||
String endDate,
|
String endDate,
|
||||||
) async {
|
) async {
|
||||||
@ -141,8 +134,7 @@ class OrderRemoteDatasource {
|
|||||||
print("âś… getPaymentMethodByRangeDate API call successful");
|
print("âś… getPaymentMethodByRangeDate API call successful");
|
||||||
return Right(PaymentMethodResponseModel.fromJson(response.body));
|
return Right(PaymentMethodResponseModel.fromJson(response.body));
|
||||||
} else {
|
} else {
|
||||||
print(
|
print("❌ getPaymentMethodByRangeDate API call failed - Status: ${response.statusCode}");
|
||||||
"❌ getPaymentMethodByRangeDate API call failed - Status: ${response.statusCode}");
|
|
||||||
print("❌ Error Response: ${response.body}");
|
print("❌ Error Response: ${response.body}");
|
||||||
return const Left("Failed Load Payment Method Data");
|
return const Left("Failed Load Payment Method Data");
|
||||||
}
|
}
|
||||||
@ -170,17 +162,16 @@ class OrderRemoteDatasource {
|
|||||||
'order_items': orderItems,
|
'order_items': orderItems,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
print("📥 Add Order Items HTTP Status Code: ${response.statusCode}");
|
print("📥 Add Order Items HTTP Status Code: ${response.statusCode}");
|
||||||
print("📥 Add Order Items Response Body: ${response.body}");
|
print("📥 Add Order Items Response Body: ${response.body}");
|
||||||
print("📥 Add Order Items Response Headers: ${response.headers}");
|
print("📥 Add Order Items Response Headers: ${response.headers}");
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print("âś… addOrderItems API call successful");
|
print("âś… addOrderItems API call successful");
|
||||||
return const Right(true);
|
return const Right(true);
|
||||||
} else {
|
} else {
|
||||||
print(
|
print("❌ addOrderItems API call failed - Status: ${response.statusCode}");
|
||||||
"❌ addOrderItems API call failed - Status: ${response.statusCode}");
|
|
||||||
print("❌ Error Response: ${response.body}");
|
print("❌ Error Response: ${response.body}");
|
||||||
return Left("Failed to add order items: ${response.body}");
|
return Left("Failed to add order items: ${response.body}");
|
||||||
}
|
}
|
||||||
@ -189,38 +180,4 @@ class OrderRemoteDatasource {
|
|||||||
return Left("Failed: $e");
|
return Left("Failed: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Api
|
|
||||||
Future<Either<String, bool>> createOrder(OrderRequestModel orderModel) async {
|
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
|
||||||
final url = '${Variables.baseUrl}/api/v1/orders';
|
|
||||||
|
|
||||||
try {
|
|
||||||
final response = await dio.post(
|
|
||||||
url,
|
|
||||||
data: orderModel.toMap(),
|
|
||||||
options: Options(
|
|
||||||
headers: {
|
|
||||||
'Authorization': 'Bearer ${authData.token}',
|
|
||||||
'Accept': 'application/json',
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return const Right(true);
|
|
||||||
} else {
|
|
||||||
return const Left('Gagal membuat pesanan');
|
|
||||||
}
|
|
||||||
} on DioException catch (e) {
|
|
||||||
final errorMessage = e.response?.data['message'] ?? 'Kesalahan jaringan';
|
|
||||||
log("đź’Ą Dio error: ${e.message}");
|
|
||||||
log("đź’Ą Dio response: ${e.response?.data}");
|
|
||||||
return Left(errorMessage);
|
|
||||||
} catch (e) {
|
|
||||||
log("đź’Ą Unexpected error: $e");
|
|
||||||
return const Left('Terjadi kesalahan tak terduga');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:dio/dio.dart';
|
|
||||||
import 'package:enaklo_pos/core/network/dio_client.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
|
||||||
import '../../core/constants/variables.dart';
|
|
||||||
import 'auth_local_datasource.dart';
|
|
||||||
|
|
||||||
class OutletRemoteDataSource {
|
|
||||||
final Dio dio = DioClient.instance;
|
|
||||||
|
|
||||||
Future<Either<String, OutletResponse>> getOutlets() async {
|
|
||||||
try {
|
|
||||||
final authData = await AuthLocalDataSource().getAuthData();
|
|
||||||
final url = '${Variables.baseUrl}/api/v1/outlets/list';
|
|
||||||
|
|
||||||
final response = await dio.get(
|
|
||||||
url,
|
|
||||||
queryParameters: {
|
|
||||||
'organization_id': authData.user?.organizationId,
|
|
||||||
},
|
|
||||||
options: Options(
|
|
||||||
headers: {
|
|
||||||
'Authorization': 'Bearer ${authData.token}',
|
|
||||||
'Accept': 'application/json',
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
return Right(OutletResponse.fromMap(response.data));
|
|
||||||
} else {
|
|
||||||
return const Left('Failed to get outlets');
|
|
||||||
}
|
|
||||||
} on DioException catch (e) {
|
|
||||||
log("Dio error: ${e.message}");
|
|
||||||
return Left(e.response?.data['message'] ?? 'Gagal mengambil outlet');
|
|
||||||
} catch (e) {
|
|
||||||
log("Unexpected error: $e");
|
|
||||||
return const Left('Unexpected error occurred');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,5 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
import 'package:enaklo_pos/core/constants/theme.dart';
|
import 'package:enaklo_pos/core/constants/theme.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
||||||
@ -224,12 +221,6 @@ class _MyAppState extends State<MyApp> {
|
|||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => ProductLoaderBloc(ProductRemoteDatasource()),
|
create: (context) => ProductLoaderBloc(ProductRemoteDatasource()),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
|
||||||
create: (context) => OrderFormBloc(OrderRemoteDatasource()),
|
|
||||||
),
|
|
||||||
BlocProvider(
|
|
||||||
create: (context) => OutletLoaderBloc(OutletRemoteDataSource()),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
|
|||||||
@ -1,59 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:enaklo_pos/data/datasources/auth_local_datasource.dart';
|
|
||||||
import 'package:enaklo_pos/data/datasources/order_remote_datasource.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_request.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
|
|
||||||
part 'order_form_event.dart';
|
|
||||||
part 'order_form_state.dart';
|
|
||||||
part 'order_form_bloc.freezed.dart';
|
|
||||||
|
|
||||||
class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
|
||||||
final OrderRemoteDatasource _orderRemoteDatasource;
|
|
||||||
OrderFormBloc(this._orderRemoteDatasource) : super(OrderFormState.initial()) {
|
|
||||||
on<_Create>(
|
|
||||||
(event, emit) async {
|
|
||||||
emit(const _Loading());
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Convert ProductQuantity list to the format expected by the API
|
|
||||||
|
|
||||||
final userData = await AuthLocalDataSource().getAuthData();
|
|
||||||
|
|
||||||
final orderItems = OrderRequestModel(
|
|
||||||
customerName: event.customerName,
|
|
||||||
notes: '',
|
|
||||||
orderType: event.orderType.name,
|
|
||||||
tableNumber: event.tableNumber.toString(),
|
|
||||||
outletId: userData.user?.outletId,
|
|
||||||
userId: userData.user?.id,
|
|
||||||
orderItems: event.items
|
|
||||||
.map(
|
|
||||||
(productQuantity) => OrderItemRequest(
|
|
||||||
productId: productQuantity.product.id,
|
|
||||||
quantity: productQuantity.quantity,
|
|
||||||
notes: productQuantity.notes,
|
|
||||||
unitPrice: productQuantity.product.price,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
|
|
||||||
final result = await _orderRemoteDatasource.createOrder(orderItems);
|
|
||||||
|
|
||||||
result.fold(
|
|
||||||
(error) => emit(_Error(error)),
|
|
||||||
(success) => emit(const _Success()),
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
log("Error in AddOrderItemsBloc: $e");
|
|
||||||
emit(_Error("Failed to add order items: $e"));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,900 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'order_form_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$OrderFormEvent {
|
|
||||||
List<ProductQuantity> get items => throw _privateConstructorUsedError;
|
|
||||||
String get customerName => throw _privateConstructorUsedError;
|
|
||||||
OrderType get orderType => throw _privateConstructorUsedError;
|
|
||||||
String get tableNumber => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
|
||||||
OrderType orderType, String tableNumber)
|
|
||||||
create,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
|
||||||
OrderType orderType, String tableNumber)?
|
|
||||||
create,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
|
||||||
OrderType orderType, String tableNumber)?
|
|
||||||
create,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Create value) create,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Create value)? create,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Create value)? create,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$OrderFormEventCopyWith<OrderFormEvent> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $OrderFormEventCopyWith<$Res> {
|
|
||||||
factory $OrderFormEventCopyWith(
|
|
||||||
OrderFormEvent value, $Res Function(OrderFormEvent) then) =
|
|
||||||
_$OrderFormEventCopyWithImpl<$Res, OrderFormEvent>;
|
|
||||||
@useResult
|
|
||||||
$Res call(
|
|
||||||
{List<ProductQuantity> items,
|
|
||||||
String customerName,
|
|
||||||
OrderType orderType,
|
|
||||||
String tableNumber});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$OrderFormEventCopyWithImpl<$Res, $Val extends OrderFormEvent>
|
|
||||||
implements $OrderFormEventCopyWith<$Res> {
|
|
||||||
_$OrderFormEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? items = null,
|
|
||||||
Object? customerName = null,
|
|
||||||
Object? orderType = null,
|
|
||||||
Object? tableNumber = null,
|
|
||||||
}) {
|
|
||||||
return _then(_value.copyWith(
|
|
||||||
items: null == items
|
|
||||||
? _value.items
|
|
||||||
: items // ignore: cast_nullable_to_non_nullable
|
|
||||||
as List<ProductQuantity>,
|
|
||||||
customerName: null == customerName
|
|
||||||
? _value.customerName
|
|
||||||
: customerName // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
orderType: null == orderType
|
|
||||||
? _value.orderType
|
|
||||||
: orderType // ignore: cast_nullable_to_non_nullable
|
|
||||||
as OrderType,
|
|
||||||
tableNumber: null == tableNumber
|
|
||||||
? _value.tableNumber
|
|
||||||
: tableNumber // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
) as $Val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$CreateImplCopyWith<$Res>
|
|
||||||
implements $OrderFormEventCopyWith<$Res> {
|
|
||||||
factory _$$CreateImplCopyWith(
|
|
||||||
_$CreateImpl value, $Res Function(_$CreateImpl) then) =
|
|
||||||
__$$CreateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call(
|
|
||||||
{List<ProductQuantity> items,
|
|
||||||
String customerName,
|
|
||||||
OrderType orderType,
|
|
||||||
String tableNumber});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$CreateImplCopyWithImpl<$Res>
|
|
||||||
extends _$OrderFormEventCopyWithImpl<$Res, _$CreateImpl>
|
|
||||||
implements _$$CreateImplCopyWith<$Res> {
|
|
||||||
__$$CreateImplCopyWithImpl(
|
|
||||||
_$CreateImpl _value, $Res Function(_$CreateImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? items = null,
|
|
||||||
Object? customerName = null,
|
|
||||||
Object? orderType = null,
|
|
||||||
Object? tableNumber = null,
|
|
||||||
}) {
|
|
||||||
return _then(_$CreateImpl(
|
|
||||||
items: null == items
|
|
||||||
? _value._items
|
|
||||||
: items // ignore: cast_nullable_to_non_nullable
|
|
||||||
as List<ProductQuantity>,
|
|
||||||
customerName: null == customerName
|
|
||||||
? _value.customerName
|
|
||||||
: customerName // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
orderType: null == orderType
|
|
||||||
? _value.orderType
|
|
||||||
: orderType // ignore: cast_nullable_to_non_nullable
|
|
||||||
as OrderType,
|
|
||||||
tableNumber: null == tableNumber
|
|
||||||
? _value.tableNumber
|
|
||||||
: tableNumber // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$CreateImpl implements _Create {
|
|
||||||
const _$CreateImpl(
|
|
||||||
{required final List<ProductQuantity> items,
|
|
||||||
required this.customerName,
|
|
||||||
required this.orderType,
|
|
||||||
required this.tableNumber})
|
|
||||||
: _items = items;
|
|
||||||
|
|
||||||
final List<ProductQuantity> _items;
|
|
||||||
@override
|
|
||||||
List<ProductQuantity> get items {
|
|
||||||
if (_items is EqualUnmodifiableListView) return _items;
|
|
||||||
// ignore: implicit_dynamic_type
|
|
||||||
return EqualUnmodifiableListView(_items);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String customerName;
|
|
||||||
@override
|
|
||||||
final OrderType orderType;
|
|
||||||
@override
|
|
||||||
final String tableNumber;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OrderFormEvent.create(items: $items, customerName: $customerName, orderType: $orderType, tableNumber: $tableNumber)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$CreateImpl &&
|
|
||||||
const DeepCollectionEquality().equals(other._items, _items) &&
|
|
||||||
(identical(other.customerName, customerName) ||
|
|
||||||
other.customerName == customerName) &&
|
|
||||||
(identical(other.orderType, orderType) ||
|
|
||||||
other.orderType == orderType) &&
|
|
||||||
(identical(other.tableNumber, tableNumber) ||
|
|
||||||
other.tableNumber == tableNumber));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(
|
|
||||||
runtimeType,
|
|
||||||
const DeepCollectionEquality().hash(_items),
|
|
||||||
customerName,
|
|
||||||
orderType,
|
|
||||||
tableNumber);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$CreateImplCopyWith<_$CreateImpl> get copyWith =>
|
|
||||||
__$$CreateImplCopyWithImpl<_$CreateImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(List<ProductQuantity> items, String customerName,
|
|
||||||
OrderType orderType, String tableNumber)
|
|
||||||
create,
|
|
||||||
}) {
|
|
||||||
return create(items, customerName, orderType, tableNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(List<ProductQuantity> items, String customerName,
|
|
||||||
OrderType orderType, String tableNumber)?
|
|
||||||
create,
|
|
||||||
}) {
|
|
||||||
return create?.call(items, customerName, orderType, tableNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(List<ProductQuantity> items, String customerName,
|
|
||||||
OrderType orderType, String tableNumber)?
|
|
||||||
create,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (create != null) {
|
|
||||||
return create(items, customerName, orderType, tableNumber);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Create value) create,
|
|
||||||
}) {
|
|
||||||
return create(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Create value)? create,
|
|
||||||
}) {
|
|
||||||
return create?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Create value)? create,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (create != null) {
|
|
||||||
return create(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Create implements OrderFormEvent {
|
|
||||||
const factory _Create(
|
|
||||||
{required final List<ProductQuantity> items,
|
|
||||||
required final String customerName,
|
|
||||||
required final OrderType orderType,
|
|
||||||
required final String tableNumber}) = _$CreateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<ProductQuantity> get items;
|
|
||||||
@override
|
|
||||||
String get customerName;
|
|
||||||
@override
|
|
||||||
OrderType get orderType;
|
|
||||||
@override
|
|
||||||
String get tableNumber;
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$CreateImplCopyWith<_$CreateImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$OrderFormState {
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function() success,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function()? success,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function()? success,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Success value) success,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Success value)? success,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Success value)? success,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $OrderFormStateCopyWith<$Res> {
|
|
||||||
factory $OrderFormStateCopyWith(
|
|
||||||
OrderFormState value, $Res Function(OrderFormState) then) =
|
|
||||||
_$OrderFormStateCopyWithImpl<$Res, OrderFormState>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
|
|
||||||
implements $OrderFormStateCopyWith<$Res> {
|
|
||||||
_$OrderFormStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$InitialImplCopyWith<$Res> {
|
|
||||||
factory _$$InitialImplCopyWith(
|
|
||||||
_$InitialImpl value, $Res Function(_$InitialImpl) then) =
|
|
||||||
__$$InitialImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$InitialImplCopyWithImpl<$Res>
|
|
||||||
extends _$OrderFormStateCopyWithImpl<$Res, _$InitialImpl>
|
|
||||||
implements _$$InitialImplCopyWith<$Res> {
|
|
||||||
__$$InitialImplCopyWithImpl(
|
|
||||||
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$InitialImpl implements _Initial {
|
|
||||||
const _$InitialImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OrderFormState.initial()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$InitialImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function() success,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return initial();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function()? success,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return initial?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function()? success,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (initial != null) {
|
|
||||||
return initial();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Success value) success,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return initial(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Success value)? success,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return initial?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Success value)? success,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (initial != null) {
|
|
||||||
return initial(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Initial implements OrderFormState {
|
|
||||||
const factory _Initial() = _$InitialImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$LoadingImplCopyWith<$Res> {
|
|
||||||
factory _$$LoadingImplCopyWith(
|
|
||||||
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
|
||||||
__$$LoadingImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$LoadingImplCopyWithImpl<$Res>
|
|
||||||
extends _$OrderFormStateCopyWithImpl<$Res, _$LoadingImpl>
|
|
||||||
implements _$$LoadingImplCopyWith<$Res> {
|
|
||||||
__$$LoadingImplCopyWithImpl(
|
|
||||||
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$LoadingImpl implements _Loading {
|
|
||||||
const _$LoadingImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OrderFormState.loading()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$LoadingImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function() success,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return loading();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function()? success,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return loading?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function()? success,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (loading != null) {
|
|
||||||
return loading();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Success value) success,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return loading(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Success value)? success,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return loading?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Success value)? success,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (loading != null) {
|
|
||||||
return loading(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Loading implements OrderFormState {
|
|
||||||
const factory _Loading() = _$LoadingImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$SuccessImplCopyWith<$Res> {
|
|
||||||
factory _$$SuccessImplCopyWith(
|
|
||||||
_$SuccessImpl value, $Res Function(_$SuccessImpl) then) =
|
|
||||||
__$$SuccessImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$SuccessImplCopyWithImpl<$Res>
|
|
||||||
extends _$OrderFormStateCopyWithImpl<$Res, _$SuccessImpl>
|
|
||||||
implements _$$SuccessImplCopyWith<$Res> {
|
|
||||||
__$$SuccessImplCopyWithImpl(
|
|
||||||
_$SuccessImpl _value, $Res Function(_$SuccessImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$SuccessImpl implements _Success {
|
|
||||||
const _$SuccessImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OrderFormState.success()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$SuccessImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function() success,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function()? success,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return success?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function()? success,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (success != null) {
|
|
||||||
return success();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Success value) success,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return success(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Success value)? success,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return success?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Success value)? success,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (success != null) {
|
|
||||||
return success(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Success implements OrderFormState {
|
|
||||||
const factory _Success() = _$SuccessImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$ErrorImplCopyWith<$Res> {
|
|
||||||
factory _$$ErrorImplCopyWith(
|
|
||||||
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
|
||||||
__$$ErrorImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({String message});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$ErrorImplCopyWithImpl<$Res>
|
|
||||||
extends _$OrderFormStateCopyWithImpl<$Res, _$ErrorImpl>
|
|
||||||
implements _$$ErrorImplCopyWith<$Res> {
|
|
||||||
__$$ErrorImplCopyWithImpl(
|
|
||||||
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? message = null,
|
|
||||||
}) {
|
|
||||||
return _then(_$ErrorImpl(
|
|
||||||
null == message
|
|
||||||
? _value.message
|
|
||||||
: message // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$ErrorImpl implements _Error {
|
|
||||||
const _$ErrorImpl(this.message);
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String message;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OrderFormState.error(message: $message)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$ErrorImpl &&
|
|
||||||
(identical(other.message, message) || other.message == message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, message);
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
|
||||||
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function() success,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function()? success,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return error?.call(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function()? success,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (error != null) {
|
|
||||||
return error(message);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Success value) success,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return error(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Success value)? success,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return error?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Success value)? success,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (error != null) {
|
|
||||||
return error(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Error implements OrderFormState {
|
|
||||||
const factory _Error(final String message) = _$ErrorImpl;
|
|
||||||
|
|
||||||
String get message;
|
|
||||||
|
|
||||||
/// Create a copy of OrderFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
part of 'order_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class OrderFormEvent with _$OrderFormEvent {
|
|
||||||
const factory OrderFormEvent.create({
|
|
||||||
required List<ProductQuantity> items,
|
|
||||||
required String customerName,
|
|
||||||
required OrderType orderType,
|
|
||||||
required String tableNumber,
|
|
||||||
}) = _Create;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'order_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class OrderFormState with _$OrderFormState {
|
|
||||||
const factory OrderFormState.initial() = _Initial;
|
|
||||||
const factory OrderFormState.loading() = _Loading;
|
|
||||||
const factory OrderFormState.success() = _Success;
|
|
||||||
const factory OrderFormState.error(String message) = _Error;
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:enaklo_pos/data/datasources/outlet_remote_data_source.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
|
|
||||||
part 'outlet_loader_event.dart';
|
|
||||||
part 'outlet_loader_state.dart';
|
|
||||||
part 'outlet_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
class OutletLoaderBloc extends Bloc<OutletLoaderEvent, OutletLoaderState> {
|
|
||||||
final OutletRemoteDataSource _outletRemoteDataSource;
|
|
||||||
OutletLoaderBloc(this._outletRemoteDataSource)
|
|
||||||
: super(OutletLoaderState.initial()) {
|
|
||||||
on<_GetOutlet>((event, emit) async {
|
|
||||||
emit(const _Loading());
|
|
||||||
final result = await _outletRemoteDataSource.getOutlets();
|
|
||||||
result.fold(
|
|
||||||
(l) => emit(_Error(l)),
|
|
||||||
(r) => emit(_Loaded(r.data?.outlets ?? [])),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,790 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'outlet_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$OutletLoaderEvent {
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() getOutlet,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? getOutlet,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? getOutlet,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_GetOutlet value) getOutlet,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_GetOutlet value)? getOutlet,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_GetOutlet value)? getOutlet,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $OutletLoaderEventCopyWith<$Res> {
|
|
||||||
factory $OutletLoaderEventCopyWith(
|
|
||||||
OutletLoaderEvent value, $Res Function(OutletLoaderEvent) then) =
|
|
||||||
_$OutletLoaderEventCopyWithImpl<$Res, OutletLoaderEvent>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$OutletLoaderEventCopyWithImpl<$Res, $Val extends OutletLoaderEvent>
|
|
||||||
implements $OutletLoaderEventCopyWith<$Res> {
|
|
||||||
_$OutletLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$GetOutletImplCopyWith<$Res> {
|
|
||||||
factory _$$GetOutletImplCopyWith(
|
|
||||||
_$GetOutletImpl value, $Res Function(_$GetOutletImpl) then) =
|
|
||||||
__$$GetOutletImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$GetOutletImplCopyWithImpl<$Res>
|
|
||||||
extends _$OutletLoaderEventCopyWithImpl<$Res, _$GetOutletImpl>
|
|
||||||
implements _$$GetOutletImplCopyWith<$Res> {
|
|
||||||
__$$GetOutletImplCopyWithImpl(
|
|
||||||
_$GetOutletImpl _value, $Res Function(_$GetOutletImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$GetOutletImpl implements _GetOutlet {
|
|
||||||
const _$GetOutletImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OutletLoaderEvent.getOutlet()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$GetOutletImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() getOutlet,
|
|
||||||
}) {
|
|
||||||
return getOutlet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? getOutlet,
|
|
||||||
}) {
|
|
||||||
return getOutlet?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? getOutlet,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (getOutlet != null) {
|
|
||||||
return getOutlet();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_GetOutlet value) getOutlet,
|
|
||||||
}) {
|
|
||||||
return getOutlet(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_GetOutlet value)? getOutlet,
|
|
||||||
}) {
|
|
||||||
return getOutlet?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_GetOutlet value)? getOutlet,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (getOutlet != null) {
|
|
||||||
return getOutlet(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _GetOutlet implements OutletLoaderEvent {
|
|
||||||
const factory _GetOutlet() = _$GetOutletImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$OutletLoaderState {
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function(List<Outlet> outlets) loaded,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Loaded value) loaded,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Loaded value)? loaded,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Loaded value)? loaded,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $OutletLoaderStateCopyWith<$Res> {
|
|
||||||
factory $OutletLoaderStateCopyWith(
|
|
||||||
OutletLoaderState value, $Res Function(OutletLoaderState) then) =
|
|
||||||
_$OutletLoaderStateCopyWithImpl<$Res, OutletLoaderState>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$OutletLoaderStateCopyWithImpl<$Res, $Val extends OutletLoaderState>
|
|
||||||
implements $OutletLoaderStateCopyWith<$Res> {
|
|
||||||
_$OutletLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$InitialImplCopyWith<$Res> {
|
|
||||||
factory _$$InitialImplCopyWith(
|
|
||||||
_$InitialImpl value, $Res Function(_$InitialImpl) then) =
|
|
||||||
__$$InitialImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$InitialImplCopyWithImpl<$Res>
|
|
||||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$InitialImpl>
|
|
||||||
implements _$$InitialImplCopyWith<$Res> {
|
|
||||||
__$$InitialImplCopyWithImpl(
|
|
||||||
_$InitialImpl _value, $Res Function(_$InitialImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$InitialImpl implements _Initial {
|
|
||||||
const _$InitialImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OutletLoaderState.initial()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$InitialImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function(List<Outlet> outlets) loaded,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return initial();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return initial?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (initial != null) {
|
|
||||||
return initial();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Loaded value) loaded,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return initial(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Loaded value)? loaded,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return initial?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Loaded value)? loaded,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (initial != null) {
|
|
||||||
return initial(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Initial implements OutletLoaderState {
|
|
||||||
const factory _Initial() = _$InitialImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$LoadingImplCopyWith<$Res> {
|
|
||||||
factory _$$LoadingImplCopyWith(
|
|
||||||
_$LoadingImpl value, $Res Function(_$LoadingImpl) then) =
|
|
||||||
__$$LoadingImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$LoadingImplCopyWithImpl<$Res>
|
|
||||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$LoadingImpl>
|
|
||||||
implements _$$LoadingImplCopyWith<$Res> {
|
|
||||||
__$$LoadingImplCopyWithImpl(
|
|
||||||
_$LoadingImpl _value, $Res Function(_$LoadingImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$LoadingImpl implements _Loading {
|
|
||||||
const _$LoadingImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OutletLoaderState.loading()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$LoadingImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function(List<Outlet> outlets) loaded,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return loading();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return loading?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (loading != null) {
|
|
||||||
return loading();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Loaded value) loaded,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return loading(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Loaded value)? loaded,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return loading?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Loaded value)? loaded,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (loading != null) {
|
|
||||||
return loading(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Loading implements OutletLoaderState {
|
|
||||||
const factory _Loading() = _$LoadingImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$LoadedImplCopyWith<$Res> {
|
|
||||||
factory _$$LoadedImplCopyWith(
|
|
||||||
_$LoadedImpl value, $Res Function(_$LoadedImpl) then) =
|
|
||||||
__$$LoadedImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({List<Outlet> outlets});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$LoadedImplCopyWithImpl<$Res>
|
|
||||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$LoadedImpl>
|
|
||||||
implements _$$LoadedImplCopyWith<$Res> {
|
|
||||||
__$$LoadedImplCopyWithImpl(
|
|
||||||
_$LoadedImpl _value, $Res Function(_$LoadedImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? outlets = null,
|
|
||||||
}) {
|
|
||||||
return _then(_$LoadedImpl(
|
|
||||||
null == outlets
|
|
||||||
? _value._outlets
|
|
||||||
: outlets // ignore: cast_nullable_to_non_nullable
|
|
||||||
as List<Outlet>,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$LoadedImpl implements _Loaded {
|
|
||||||
const _$LoadedImpl(final List<Outlet> outlets) : _outlets = outlets;
|
|
||||||
|
|
||||||
final List<Outlet> _outlets;
|
|
||||||
@override
|
|
||||||
List<Outlet> get outlets {
|
|
||||||
if (_outlets is EqualUnmodifiableListView) return _outlets;
|
|
||||||
// ignore: implicit_dynamic_type
|
|
||||||
return EqualUnmodifiableListView(_outlets);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OutletLoaderState.loaded(outlets: $outlets)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$LoadedImpl &&
|
|
||||||
const DeepCollectionEquality().equals(other._outlets, _outlets));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, const DeepCollectionEquality().hash(_outlets));
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$LoadedImplCopyWith<_$LoadedImpl> get copyWith =>
|
|
||||||
__$$LoadedImplCopyWithImpl<_$LoadedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function(List<Outlet> outlets) loaded,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return loaded(outlets);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return loaded?.call(outlets);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (loaded != null) {
|
|
||||||
return loaded(outlets);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Loaded value) loaded,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return loaded(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Loaded value)? loaded,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return loaded?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Loaded value)? loaded,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (loaded != null) {
|
|
||||||
return loaded(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Loaded implements OutletLoaderState {
|
|
||||||
const factory _Loaded(final List<Outlet> outlets) = _$LoadedImpl;
|
|
||||||
|
|
||||||
List<Outlet> get outlets;
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$LoadedImplCopyWith<_$LoadedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$ErrorImplCopyWith<$Res> {
|
|
||||||
factory _$$ErrorImplCopyWith(
|
|
||||||
_$ErrorImpl value, $Res Function(_$ErrorImpl) then) =
|
|
||||||
__$$ErrorImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({String message});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$ErrorImplCopyWithImpl<$Res>
|
|
||||||
extends _$OutletLoaderStateCopyWithImpl<$Res, _$ErrorImpl>
|
|
||||||
implements _$$ErrorImplCopyWith<$Res> {
|
|
||||||
__$$ErrorImplCopyWithImpl(
|
|
||||||
_$ErrorImpl _value, $Res Function(_$ErrorImpl) _then)
|
|
||||||
: super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? message = null,
|
|
||||||
}) {
|
|
||||||
return _then(_$ErrorImpl(
|
|
||||||
null == message
|
|
||||||
? _value.message
|
|
||||||
: message // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$ErrorImpl implements _Error {
|
|
||||||
const _$ErrorImpl(this.message);
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String message;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'OutletLoaderState.error(message: $message)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$ErrorImpl &&
|
|
||||||
(identical(other.message, message) || other.message == message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, message);
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
|
||||||
__$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function() initial,
|
|
||||||
required TResult Function() loading,
|
|
||||||
required TResult Function(List<Outlet> outlets) loaded,
|
|
||||||
required TResult Function(String message) error,
|
|
||||||
}) {
|
|
||||||
return error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function()? initial,
|
|
||||||
TResult? Function()? loading,
|
|
||||||
TResult? Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult? Function(String message)? error,
|
|
||||||
}) {
|
|
||||||
return error?.call(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function()? initial,
|
|
||||||
TResult Function()? loading,
|
|
||||||
TResult Function(List<Outlet> outlets)? loaded,
|
|
||||||
TResult Function(String message)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (error != null) {
|
|
||||||
return error(message);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Initial value) initial,
|
|
||||||
required TResult Function(_Loading value) loading,
|
|
||||||
required TResult Function(_Loaded value) loaded,
|
|
||||||
required TResult Function(_Error value) error,
|
|
||||||
}) {
|
|
||||||
return error(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Initial value)? initial,
|
|
||||||
TResult? Function(_Loading value)? loading,
|
|
||||||
TResult? Function(_Loaded value)? loaded,
|
|
||||||
TResult? Function(_Error value)? error,
|
|
||||||
}) {
|
|
||||||
return error?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Initial value)? initial,
|
|
||||||
TResult Function(_Loading value)? loading,
|
|
||||||
TResult Function(_Loaded value)? loaded,
|
|
||||||
TResult Function(_Error value)? error,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (error != null) {
|
|
||||||
return error(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Error implements OutletLoaderState {
|
|
||||||
const factory _Error(final String message) = _$ErrorImpl;
|
|
||||||
|
|
||||||
String get message;
|
|
||||||
|
|
||||||
/// Create a copy of OutletLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$ErrorImplCopyWith<_$ErrorImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
part of 'outlet_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class OutletLoaderEvent with _$OutletLoaderEvent {
|
|
||||||
const factory OutletLoaderEvent.getOutlet() = _GetOutlet;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'outlet_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class OutletLoaderState with _$OutletLoaderState {
|
|
||||||
const factory OutletLoaderState.initial() = _Initial;
|
|
||||||
const factory OutletLoaderState.loading() = _Loading;
|
|
||||||
const factory OutletLoaderState.loaded(List<Outlet> outlets) = _Loaded;
|
|
||||||
const factory OutletLoaderState.error(String message) = _Error;
|
|
||||||
}
|
|
||||||
@ -1,40 +0,0 @@
|
|||||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/widgets/outlet_card.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
|
|
||||||
class OutletDialog extends StatelessWidget {
|
|
||||||
const OutletDialog({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return CustomModalDialog(
|
|
||||||
title: 'Outlet',
|
|
||||||
subtitle: 'Silahkan pilih outlet',
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 24.0),
|
|
||||||
child: BlocBuilder<OutletLoaderBloc, OutletLoaderState>(
|
|
||||||
builder: (context, state) {
|
|
||||||
return state.maybeWhen(
|
|
||||||
orElse: () => Center(
|
|
||||||
child: Text('Error has occured'),
|
|
||||||
),
|
|
||||||
loading: () => Center(child: CircularProgressIndicator()),
|
|
||||||
error: (message) => Center(
|
|
||||||
child: Text(message),
|
|
||||||
),
|
|
||||||
loaded: (outlets) => Column(
|
|
||||||
children: List.generate(
|
|
||||||
outlets.length,
|
|
||||||
(index) => OutletCard(
|
|
||||||
outlet: outlets[index],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,23 +5,11 @@ import 'package:enaklo_pos/core/constants/colors.dart';
|
|||||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/get_table_status/get_table_status_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/get_table_status/get_table_status_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/order_form/order_form_bloc.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
class PaymentSaveDialog extends StatefulWidget {
|
class PaymentSaveDialog extends StatefulWidget {
|
||||||
final TableModel? selectedTable;
|
const PaymentSaveDialog({super.key});
|
||||||
final String customerName;
|
|
||||||
final OrderType orderType;
|
|
||||||
final List<ProductQuantity> items;
|
|
||||||
const PaymentSaveDialog(
|
|
||||||
{super.key,
|
|
||||||
required this.selectedTable,
|
|
||||||
required this.customerName,
|
|
||||||
required this.orderType,
|
|
||||||
required this.items});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PaymentSaveDialog> createState() => _PaymentSaveDialogState();
|
State<PaymentSaveDialog> createState() => _PaymentSaveDialogState();
|
||||||
@ -29,15 +17,6 @@ class PaymentSaveDialog extends StatefulWidget {
|
|||||||
|
|
||||||
class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
||||||
TableModel? selectTable;
|
TableModel? selectTable;
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
if (widget.selectedTable != null) {
|
|
||||||
selectTable = widget.selectedTable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomModalDialog(
|
return CustomModalDialog(
|
||||||
@ -133,16 +112,7 @@ class _PaymentSaveDialogState extends State<PaymentSaveDialog> {
|
|||||||
),
|
),
|
||||||
SpaceHeight(24),
|
SpaceHeight(24),
|
||||||
Button.filled(
|
Button.filled(
|
||||||
onPressed: () {
|
onPressed: () {},
|
||||||
context.read<OrderFormBloc>().add(
|
|
||||||
OrderFormEvent.create(
|
|
||||||
items: widget.items,
|
|
||||||
customerName: widget.customerName,
|
|
||||||
orderType: widget.orderType,
|
|
||||||
tableNumber: selectTable!.tableName.toString(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
label: "Simpan",
|
label: "Simpan",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,25 +1,12 @@
|
|||||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
import 'package:enaklo_pos/core/components/spaces.dart';
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
import 'package:enaklo_pos/core/constants/colors.dart';
|
||||||
import 'package:enaklo_pos/data/models/response/table_model.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/payment_add_order_dialog.dart';
|
import 'package:enaklo_pos/presentation/home/dialog/payment_add_order_dialog.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/payment_save_dialog.dart';
|
import 'package:enaklo_pos/presentation/home/dialog/payment_save_dialog.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class SaveDialog extends StatelessWidget {
|
class SaveDialog extends StatelessWidget {
|
||||||
final TableModel? selectedTable;
|
const SaveDialog({super.key});
|
||||||
final String customerName;
|
|
||||||
final OrderType orderType;
|
|
||||||
final List<ProductQuantity> items;
|
|
||||||
|
|
||||||
const SaveDialog(
|
|
||||||
{super.key,
|
|
||||||
required this.selectedTable,
|
|
||||||
required this.customerName,
|
|
||||||
required this.orderType,
|
|
||||||
required this.items});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -36,11 +23,7 @@ class SaveDialog extends StatelessWidget {
|
|||||||
subtitle: 'Simpan pesanan dan bayar nanti',
|
subtitle: 'Simpan pesanan dan bayar nanti',
|
||||||
onTap: () => showDialog(
|
onTap: () => showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => PaymentSaveDialog(
|
builder: (context) => const PaymentSaveDialog(),
|
||||||
selectedTable: selectedTable,
|
|
||||||
customerName: customerName,
|
|
||||||
orderType: orderType,
|
|
||||||
items: items),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SpaceHeight(16.0),
|
SpaceHeight(16.0),
|
||||||
|
|||||||
@ -1,84 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
class OrderRequestModel {
|
|
||||||
final String? outletId;
|
|
||||||
final String? userId;
|
|
||||||
final String? tableNumber;
|
|
||||||
final String? orderType;
|
|
||||||
final String? notes;
|
|
||||||
final List<OrderItemRequest>? orderItems;
|
|
||||||
final String? customerName;
|
|
||||||
|
|
||||||
OrderRequestModel({
|
|
||||||
this.outletId,
|
|
||||||
this.userId,
|
|
||||||
this.tableNumber,
|
|
||||||
this.orderType,
|
|
||||||
this.notes,
|
|
||||||
this.orderItems,
|
|
||||||
this.customerName,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory OrderRequestModel.fromJson(String str) =>
|
|
||||||
OrderRequestModel.fromMap(json.decode(str));
|
|
||||||
|
|
||||||
String toJson() => json.encode(toMap());
|
|
||||||
|
|
||||||
factory OrderRequestModel.fromMap(Map<String, dynamic> json) =>
|
|
||||||
OrderRequestModel(
|
|
||||||
outletId: json["outlet_id"],
|
|
||||||
userId: json["user_id"],
|
|
||||||
tableNumber: json["table_number"],
|
|
||||||
orderType: json["order_type"],
|
|
||||||
notes: json["notes"],
|
|
||||||
orderItems: json["order_items"] == null
|
|
||||||
? []
|
|
||||||
: List<OrderItemRequest>.from(
|
|
||||||
json["order_items"].map((x) => OrderItemRequest.fromMap(x))),
|
|
||||||
customerName: json["customer_name"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
|
||||||
"outlet_id": outletId,
|
|
||||||
"user_id": userId,
|
|
||||||
"table_number": tableNumber,
|
|
||||||
"order_type": orderType,
|
|
||||||
"notes": notes,
|
|
||||||
"order_items": orderItems == null
|
|
||||||
? []
|
|
||||||
: List<dynamic>.from(orderItems!.map((x) => x.toMap())),
|
|
||||||
"customer_name": customerName,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class OrderItemRequest {
|
|
||||||
final String? productId;
|
|
||||||
final int? quantity;
|
|
||||||
final int? unitPrice;
|
|
||||||
final String? notes;
|
|
||||||
|
|
||||||
OrderItemRequest({
|
|
||||||
this.productId,
|
|
||||||
this.quantity,
|
|
||||||
this.unitPrice,
|
|
||||||
this.notes,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory OrderItemRequest.fromJson(String str) =>
|
|
||||||
OrderItemRequest.fromMap(json.decode(str));
|
|
||||||
|
|
||||||
factory OrderItemRequest.fromMap(Map<String, dynamic> json) =>
|
|
||||||
OrderItemRequest(
|
|
||||||
productId: json["product_id"],
|
|
||||||
quantity: json["quantity"],
|
|
||||||
unitPrice: json["unit_price"]?.toDouble(),
|
|
||||||
notes: json["notes"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
|
||||||
"product_id": productId,
|
|
||||||
"quantity": quantity,
|
|
||||||
"unit_price": unitPrice,
|
|
||||||
"notes": notes,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,130 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
class OutletResponse {
|
|
||||||
final bool? success;
|
|
||||||
final OutletData? data;
|
|
||||||
final dynamic errors;
|
|
||||||
|
|
||||||
OutletResponse({
|
|
||||||
this.success,
|
|
||||||
this.data,
|
|
||||||
this.errors,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory OutletResponse.fromJson(String str) =>
|
|
||||||
OutletResponse.fromMap(json.decode(str));
|
|
||||||
|
|
||||||
String toJson() => json.encode(toMap());
|
|
||||||
|
|
||||||
factory OutletResponse.fromMap(Map<String, dynamic> json) => OutletResponse(
|
|
||||||
success: json["success"],
|
|
||||||
data: json["data"] == null ? null : OutletData.fromMap(json["data"]),
|
|
||||||
errors: json["errors"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
|
||||||
"success": success,
|
|
||||||
"data": data?.toMap(),
|
|
||||||
"errors": errors,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class OutletData {
|
|
||||||
final List<Outlet>? outlets;
|
|
||||||
final int? totalCount;
|
|
||||||
final int? page;
|
|
||||||
final int? limit;
|
|
||||||
final int? totalPages;
|
|
||||||
|
|
||||||
OutletData({
|
|
||||||
this.outlets,
|
|
||||||
this.totalCount,
|
|
||||||
this.page,
|
|
||||||
this.limit,
|
|
||||||
this.totalPages,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory OutletData.fromMap(Map<String, dynamic> json) => OutletData(
|
|
||||||
outlets: json["outlets"] == null
|
|
||||||
? []
|
|
||||||
: List<Outlet>.from(json["outlets"].map((x) => Outlet.fromMap(x))),
|
|
||||||
totalCount: json["total_count"],
|
|
||||||
page: json["page"],
|
|
||||||
limit: json["limit"],
|
|
||||||
totalPages: json["total_pages"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
|
||||||
"outlets": outlets == null
|
|
||||||
? []
|
|
||||||
: List<dynamic>.from(outlets!.map((x) => x.toMap())),
|
|
||||||
"total_count": totalCount,
|
|
||||||
"page": page,
|
|
||||||
"limit": limit,
|
|
||||||
"total_pages": totalPages,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Outlet {
|
|
||||||
final String? id;
|
|
||||||
final String? organizationId;
|
|
||||||
final String? name;
|
|
||||||
final String? address;
|
|
||||||
final String? phoneNumber;
|
|
||||||
final String? businessType;
|
|
||||||
final String? currency;
|
|
||||||
final int? taxRate;
|
|
||||||
final bool? isActive;
|
|
||||||
final DateTime? createdAt;
|
|
||||||
final DateTime? updatedAt;
|
|
||||||
|
|
||||||
Outlet({
|
|
||||||
this.id,
|
|
||||||
this.organizationId,
|
|
||||||
this.name,
|
|
||||||
this.address,
|
|
||||||
this.phoneNumber,
|
|
||||||
this.businessType,
|
|
||||||
this.currency,
|
|
||||||
this.taxRate,
|
|
||||||
this.isActive,
|
|
||||||
this.createdAt,
|
|
||||||
this.updatedAt,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory Outlet.fromMap(Map<String, dynamic> json) => Outlet(
|
|
||||||
id: json["id"],
|
|
||||||
organizationId: json["organization_id"],
|
|
||||||
name: json["name"],
|
|
||||||
address: json["address"],
|
|
||||||
phoneNumber: json["phone_number"],
|
|
||||||
businessType: json["business_type"],
|
|
||||||
currency: json["currency"],
|
|
||||||
taxRate: json["tax_rate"],
|
|
||||||
isActive: json["is_active"],
|
|
||||||
createdAt: json["created_at"] == null
|
|
||||||
? null
|
|
||||||
: DateTime.parse(json["created_at"]),
|
|
||||||
updatedAt: json["updated_at"] == null
|
|
||||||
? null
|
|
||||||
: DateTime.parse(json["updated_at"]),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toMap() => {
|
|
||||||
"id": id,
|
|
||||||
"organization_id": organizationId,
|
|
||||||
"name": name,
|
|
||||||
"address": address,
|
|
||||||
"phone_number": phoneNumber,
|
|
||||||
"business_type": businessType,
|
|
||||||
"currency": currency,
|
|
||||||
"tax_rate": taxRate,
|
|
||||||
"is_active": isActive,
|
|
||||||
"created_at": createdAt?.toIso8601String(),
|
|
||||||
"updated_at": updatedAt?.toIso8601String(),
|
|
||||||
};
|
|
||||||
|
|
||||||
factory Outlet.fromJson(String str) => Outlet.fromMap(json.decode(str));
|
|
||||||
|
|
||||||
String toJson() => json.encode(toMap());
|
|
||||||
}
|
|
||||||
@ -2,10 +2,7 @@
|
|||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
import 'package:enaklo_pos/core/components/dashed_divider.dart';
|
||||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/save_dialog.dart';
|
import 'package:enaklo_pos/presentation/home/dialog/save_dialog.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/models/order_type.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/product_quantity.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/widgets/confirm_payment_title.dart';
|
import 'package:enaklo_pos/presentation/home/widgets/confirm_payment_title.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@ -119,7 +116,6 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ConfirmPaymentTitle(
|
ConfirmPaymentTitle(
|
||||||
isBack: false,
|
|
||||||
title: 'Konfirmasi',
|
title: 'Konfirmasi',
|
||||||
subtitle: widget.isTable
|
subtitle: widget.isTable
|
||||||
? 'Orders Table ${widget.table?.tableName}'
|
? 'Orders Table ${widget.table?.tableName}'
|
||||||
@ -773,51 +769,48 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
const SpaceHeight(20.0),
|
const SpaceHeight(20.0),
|
||||||
BlocBuilder<CheckoutBloc, CheckoutState>(
|
BlocBuilder<CheckoutBloc, CheckoutState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return SingleChildScrollView(
|
return Row(
|
||||||
scrollDirection: Axis.horizontal,
|
children: [
|
||||||
child: Row(
|
Button.outlined(
|
||||||
children: [
|
width: 150.0,
|
||||||
Button.outlined(
|
onPressed: () {
|
||||||
width: 150.0,
|
totalPriceController.text =
|
||||||
onPressed: () {
|
uangPas
|
||||||
totalPriceController.text =
|
.toString()
|
||||||
uangPas
|
.currencyFormatRpV2;
|
||||||
.toString()
|
priceValue = uangPas;
|
||||||
.currencyFormatRpV2;
|
},
|
||||||
priceValue = uangPas;
|
label: 'UANG PAS',
|
||||||
},
|
),
|
||||||
label: 'UANG PAS',
|
const SpaceWidth(20.0),
|
||||||
),
|
Button.outlined(
|
||||||
const SpaceWidth(20.0),
|
width: 150.0,
|
||||||
Button.outlined(
|
onPressed: () {
|
||||||
width: 150.0,
|
totalPriceController.text =
|
||||||
onPressed: () {
|
uangPas2
|
||||||
totalPriceController.text =
|
.toString()
|
||||||
uangPas2
|
.currencyFormatRpV2;
|
||||||
.toString()
|
priceValue = uangPas2;
|
||||||
.currencyFormatRpV2;
|
},
|
||||||
priceValue = uangPas2;
|
label: uangPas2
|
||||||
},
|
.toString()
|
||||||
label: uangPas2
|
.currencyFormatRpV2,
|
||||||
.toString()
|
),
|
||||||
.currencyFormatRpV2,
|
const SpaceWidth(20.0),
|
||||||
),
|
Button.outlined(
|
||||||
const SpaceWidth(20.0),
|
width: 150.0,
|
||||||
Button.outlined(
|
onPressed: () {
|
||||||
width: 150.0,
|
totalPriceController.text =
|
||||||
onPressed: () {
|
uangPas3
|
||||||
totalPriceController.text =
|
.toString()
|
||||||
uangPas3
|
.currencyFormatRpV2;
|
||||||
.toString()
|
priceValue = uangPas3;
|
||||||
.currencyFormatRpV2;
|
},
|
||||||
priceValue = uangPas3;
|
label: uangPas3
|
||||||
},
|
.toString()
|
||||||
label: uangPas3
|
.currencyFormatRpV2,
|
||||||
.toString()
|
),
|
||||||
.currencyFormatRpV2,
|
],
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -828,83 +821,43 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocBuilder<CheckoutBloc, CheckoutState>(
|
Container(
|
||||||
builder: (context, state) {
|
padding: EdgeInsets.all(16),
|
||||||
final orderType = state.maybeWhen(
|
decoration: BoxDecoration(
|
||||||
orElse: () => OrderType.dineIn,
|
color: AppColors.white,
|
||||||
loaded: (products,
|
border: Border(
|
||||||
discountModel,
|
top: BorderSide(
|
||||||
discount,
|
color: AppColors.background,
|
||||||
discountAmount,
|
width: 1.0,
|
||||||
tax,
|
),
|
||||||
serviceCharge,
|
),
|
||||||
totalQuantity,
|
),
|
||||||
totalPrice,
|
child: Row(
|
||||||
draftName,
|
children: [
|
||||||
orderType) =>
|
Expanded(
|
||||||
orderType,
|
child: Button.outlined(
|
||||||
);
|
onPressed: () {},
|
||||||
|
label: 'Batalkan',
|
||||||
List<ProductQuantity> items = state.maybeWhen(
|
|
||||||
orElse: () => [],
|
|
||||||
loaded: (products,
|
|
||||||
discountModel,
|
|
||||||
discount,
|
|
||||||
discountAmount,
|
|
||||||
tax,
|
|
||||||
serviceCharge,
|
|
||||||
totalQuantity,
|
|
||||||
totalPrice,
|
|
||||||
draftName,
|
|
||||||
orderType) =>
|
|
||||||
products,
|
|
||||||
);
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.all(16),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.white,
|
|
||||||
border: Border(
|
|
||||||
top: BorderSide(
|
|
||||||
color: AppColors.background,
|
|
||||||
width: 1.0,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
SpaceWidth(12),
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: Button.filled(
|
||||||
child: Button.outlined(
|
onPressed: () => showDialog(
|
||||||
onPressed: () => context.pop(),
|
context: context,
|
||||||
label: 'Batalkan',
|
builder: (context) => SaveDialog()),
|
||||||
),
|
label: 'Simpan',
|
||||||
),
|
),
|
||||||
SpaceWidth(12),
|
|
||||||
Expanded(
|
|
||||||
child: Button.filled(
|
|
||||||
onPressed: () => showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => SaveDialog(
|
|
||||||
selectedTable: widget.table,
|
|
||||||
customerName:
|
|
||||||
customerController.text,
|
|
||||||
items: items,
|
|
||||||
orderType: orderType,
|
|
||||||
)),
|
|
||||||
label: 'Simpan',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SpaceWidth(12),
|
|
||||||
Expanded(
|
|
||||||
child: Button.filled(
|
|
||||||
onPressed: () {},
|
|
||||||
label: 'Bayar',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
SpaceWidth(12),
|
||||||
},
|
Expanded(
|
||||||
|
child: Button.filled(
|
||||||
|
onPressed: () {},
|
||||||
|
label: 'Bayar',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/outlet_loader/outlet_loader_bloc.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
import 'package:enaklo_pos/presentation/home/bloc/product_loader/product_loader_bloc.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/widgets/home_right_title.dart';
|
import 'package:enaklo_pos/presentation/home/widgets/home_right_title.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -59,9 +58,6 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
// Initialize checkout with tax and service charge settings
|
// Initialize checkout with tax and service charge settings
|
||||||
context.read<CheckoutBloc>().add(const CheckoutEvent.started());
|
context.read<CheckoutBloc>().add(const CheckoutEvent.started());
|
||||||
|
|
||||||
// Get Outlets
|
|
||||||
context.read<OutletLoaderBloc>().add(const OutletLoaderEvent.getOutlet());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onCategoryTap(int index) {
|
void onCategoryTap(int index) {
|
||||||
@ -494,8 +490,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
elevation: 1,
|
elevation: 1,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.push(ConfirmPaymentPage(
|
context.push(ConfirmPaymentPage(
|
||||||
isTable:
|
isTable: widget.isTable,
|
||||||
widget.table == null ? false : true,
|
|
||||||
table: widget.table,
|
table: widget.table,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class HomeRightTitle extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: context.deviceHeight * 0.15,
|
height: context.deviceHeight * 0.1,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.primary,
|
color: AppColors.primary,
|
||||||
border: Border(
|
border: Border(
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
|
||||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||||
import 'package:enaklo_pos/presentation/home/dialog/outlet_dialog.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/components/search_input.dart';
|
import '../../../core/components/search_input.dart';
|
||||||
@ -27,24 +25,12 @@ class HomeTitle extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
const Text(
|
||||||
onTap: () => showDialog(
|
'DEFAULT OUTLET',
|
||||||
context: context,
|
style: TextStyle(
|
||||||
builder: (context) => OutletDialog(),
|
color: AppColors.primary,
|
||||||
),
|
fontSize: 20,
|
||||||
child: Row(
|
fontWeight: FontWeight.w600,
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
'DEFAULT OUTLET',
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppColors.primary,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SpaceWidth(2),
|
|
||||||
Icon(Icons.keyboard_arrow_down, color: AppColors.primary),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
@ -1,53 +0,0 @@
|
|||||||
import 'package:enaklo_pos/core/components/spaces.dart';
|
|
||||||
import 'package:enaklo_pos/core/constants/colors.dart';
|
|
||||||
import 'package:enaklo_pos/presentation/home/models/outlet_model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class OutletCard extends StatelessWidget {
|
|
||||||
final Outlet outlet;
|
|
||||||
const OutletCard({super.key, required this.outlet});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 16.0,
|
|
||||||
vertical: 12.0,
|
|
||||||
),
|
|
||||||
margin: EdgeInsets.only(bottom: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.white,
|
|
||||||
border: Border.all(color: AppColors.primary),
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.store, color: AppColors.primary),
|
|
||||||
SpaceWidth(12),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
outlet.name ?? "",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
outlet.address ?? "",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 1,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -67,8 +67,8 @@ class _TableWidgetState extends State<TableWidget> {
|
|||||||
} else {
|
} else {
|
||||||
// Handle occupied table click - load draft order and navigate to payment
|
// Handle occupied table click - load draft order and navigate to payment
|
||||||
context.read<CheckoutBloc>().add(
|
context.read<CheckoutBloc>().add(
|
||||||
CheckoutEvent.loadDraftOrder(data!),
|
CheckoutEvent.loadDraftOrder(data!),
|
||||||
);
|
);
|
||||||
log("Data Draft Order: ${data!.toMap()}");
|
log("Data Draft Order: ${data!.toMap()}");
|
||||||
context.push(PaymentTablePage(
|
context.push(PaymentTablePage(
|
||||||
table: widget.table,
|
table: widget.table,
|
||||||
@ -220,8 +220,7 @@ class _TableWidgetState extends State<TableWidget> {
|
|||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: Row(
|
title: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.warning,
|
Icon(Icons.warning, color: AppColors.red),
|
||||||
color: AppColors.red),
|
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text('Void Order?'),
|
Text('Void Order?'),
|
||||||
],
|
],
|
||||||
@ -230,33 +229,24 @@ class _TableWidgetState extends State<TableWidget> {
|
|||||||
'Apakah anda yakin ingin membatalkan pesanan untuk meja ${widget.table.tableName}?\n\nPesanan akan dihapus secara permanen.'),
|
'Apakah anda yakin ingin membatalkan pesanan untuk meja ${widget.table.tableName}?\n\nPesanan akan dihapus secara permanen.'),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () =>
|
onPressed: () => Navigator.pop(context),
|
||||||
Navigator.pop(context),
|
child: Text('Tidak',
|
||||||
child: Text('Tidak',
|
style: TextStyle(color: AppColors.primary)),
|
||||||
style: TextStyle(
|
|
||||||
color: AppColors.primary)),
|
|
||||||
),
|
),
|
||||||
BlocListener<StatusTableBloc,
|
BlocListener<StatusTableBloc, StatusTableState>(
|
||||||
StatusTableState>(
|
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
state.maybeWhen(
|
state.maybeWhen(
|
||||||
orElse: () {},
|
orElse: () {},
|
||||||
success: () {
|
success: () {
|
||||||
context
|
context
|
||||||
.read<GetTableBloc>()
|
.read<GetTableBloc>()
|
||||||
.add(const GetTableEvent
|
.add(const GetTableEvent.getTables());
|
||||||
.getTables());
|
Navigator.pop(context); // Close void dialog
|
||||||
Navigator.pop(
|
Navigator.pop(context); // Close table info dialog
|
||||||
context); // Close void dialog
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
Navigator.pop(
|
|
||||||
context); // Close table info dialog
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(
|
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
content: Text(
|
content: Text('Pesanan berhasil dibatalkan'),
|
||||||
'Pesanan berhasil dibatalkan'),
|
backgroundColor: AppColors.primary,
|
||||||
backgroundColor:
|
|
||||||
AppColors.primary,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -270,31 +260,24 @@ class _TableWidgetState extends State<TableWidget> {
|
|||||||
// Void the order
|
// Void the order
|
||||||
final newTable = TableModel(
|
final newTable = TableModel(
|
||||||
id: widget.table.id,
|
id: widget.table.id,
|
||||||
tableName:
|
tableName: widget.table.tableName,
|
||||||
widget.table.tableName,
|
|
||||||
status: 'available',
|
status: 'available',
|
||||||
orderId: 0,
|
orderId: 0,
|
||||||
paymentAmount: 0,
|
paymentAmount: 0,
|
||||||
startTime: DateTime.now()
|
startTime: DateTime.now().toIso8601String(),
|
||||||
.toIso8601String(),
|
|
||||||
position: widget.table.position,
|
position: widget.table.position,
|
||||||
);
|
);
|
||||||
context
|
context.read<StatusTableBloc>().add(
|
||||||
.read<StatusTableBloc>()
|
StatusTableEvent.statusTabel(newTable),
|
||||||
.add(
|
|
||||||
StatusTableEvent
|
|
||||||
.statusTabel(newTable),
|
|
||||||
);
|
);
|
||||||
// Remove draft order from local storage
|
// Remove draft order from local storage
|
||||||
ProductLocalDatasource.instance
|
ProductLocalDatasource.instance
|
||||||
.removeDraftOrderById(
|
.removeDraftOrderById(widget.table.orderId);
|
||||||
widget.table.orderId);
|
|
||||||
log("Voided order for table: ${widget.table.tableName}");
|
log("Voided order for table: ${widget.table.tableName}");
|
||||||
},
|
},
|
||||||
child: const Text(
|
child: const Text(
|
||||||
"Ya, Batalkan",
|
"Ya, Batalkan",
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.white),
|
||||||
color: Colors.white),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -309,14 +292,14 @@ class _TableWidgetState extends State<TableWidget> {
|
|||||||
),
|
),
|
||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BlocConsumer<StatusTableBloc,
|
child: BlocConsumer<StatusTableBloc, StatusTableState>(
|
||||||
StatusTableState>(
|
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
state.maybeWhen(
|
state.maybeWhen(
|
||||||
orElse: () {},
|
orElse: () {},
|
||||||
success: () {
|
success: () {
|
||||||
context.read<GetTableBloc>().add(
|
context
|
||||||
const GetTableEvent.getTables());
|
.read<GetTableBloc>()
|
||||||
|
.add(const GetTableEvent.getTables());
|
||||||
context.pop();
|
context.pop();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -325,8 +308,7 @@ class _TableWidgetState extends State<TableWidget> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
context.pop();
|
context.pop();
|
||||||
context.read<CheckoutBloc>().add(
|
context.read<CheckoutBloc>().add(
|
||||||
CheckoutEvent.loadDraftOrder(
|
CheckoutEvent.loadDraftOrder(data!),
|
||||||
data!),
|
|
||||||
);
|
);
|
||||||
context.push(PaymentTablePage(
|
context.push(PaymentTablePage(
|
||||||
table: widget.table,
|
table: widget.table,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user