Compare commits
2 Commits
98b152cbc2
...
4ed7721bbe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ed7721bbe | ||
|
|
f12614cec9 |
@ -0,0 +1,103 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||||
|
import '../../../../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../../../components/card/error_card.dart';
|
||||||
|
import '../../../../../../components/loader/loader_with_text.dart';
|
||||||
|
import '../../widgets/printer_card.dart';
|
||||||
|
import 'setting_printer_form.dart';
|
||||||
|
|
||||||
|
class SettingPrinterBar extends StatefulWidget {
|
||||||
|
const SettingPrinterBar({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingPrinterBar> createState() => _SettingPrinterBarState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingPrinterBarState extends State<SettingPrinterBar> {
|
||||||
|
bool isEdit = false;
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
const PrinterLoaderEvent.getByCode('bar'),
|
||||||
|
);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: AppColor.background,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.isFetching) {
|
||||||
|
return const Center(child: LoaderWithText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.printer.code == '') {
|
||||||
|
return SettingPrinterForm(
|
||||||
|
code: 'bar',
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('bar'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.failureOption.fold(
|
||||||
|
() => isEdit
|
||||||
|
? SettingPrinterForm(
|
||||||
|
code: 'bar',
|
||||||
|
printer: state.printer,
|
||||||
|
onCancel: () {
|
||||||
|
setState(() {
|
||||||
|
isEdit = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('bar'),
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
isEdit = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: PrinterCard(
|
||||||
|
printer: state.printer,
|
||||||
|
onEdit: () {
|
||||||
|
setState(() {
|
||||||
|
isEdit = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(f) => f.maybeMap(
|
||||||
|
orElse: () => ErrorCard(
|
||||||
|
title: 'Error',
|
||||||
|
message: 'Terjadi Kesalahan',
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
empty: (value) => SettingPrinterForm(
|
||||||
|
code: 'bar',
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('bar'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||||
|
import '../../../../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../../../components/card/error_card.dart';
|
||||||
|
import '../../../../../../components/loader/loader_with_text.dart';
|
||||||
|
import '../../widgets/printer_card.dart';
|
||||||
|
import 'setting_printer_form.dart';
|
||||||
|
|
||||||
|
class SettingPrinterKitchen extends StatefulWidget {
|
||||||
|
const SettingPrinterKitchen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingPrinterKitchen> createState() => _SettingPrinterKitchenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingPrinterKitchenState extends State<SettingPrinterKitchen> {
|
||||||
|
bool isEdit = false;
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
const PrinterLoaderEvent.getByCode('kitchen'),
|
||||||
|
);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: AppColor.background,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.isFetching) {
|
||||||
|
return const Center(child: LoaderWithText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.printer.code == '') {
|
||||||
|
return SettingPrinterForm(
|
||||||
|
code: 'kitchen',
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('kitchen'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.failureOption.fold(
|
||||||
|
() => isEdit
|
||||||
|
? SettingPrinterForm(
|
||||||
|
code: 'kitchen',
|
||||||
|
printer: state.printer,
|
||||||
|
onCancel: () {
|
||||||
|
setState(() {
|
||||||
|
isEdit = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('kitchen'),
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
isEdit = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: PrinterCard(
|
||||||
|
printer: state.printer,
|
||||||
|
onEdit: () {
|
||||||
|
setState(() {
|
||||||
|
isEdit = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(f) => f.maybeMap(
|
||||||
|
orElse: () => ErrorCard(
|
||||||
|
title: 'Error',
|
||||||
|
message: 'Terjadi Kesalahan',
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
empty: (value) => SettingPrinterForm(
|
||||||
|
code: 'kitchen',
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('kitchen'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
|
import '../../../../../../../application/printer/printer_loader/printer_loader_bloc.dart';
|
||||||
|
import '../../../../../../../common/theme/theme.dart';
|
||||||
|
import '../../../../../../components/card/error_card.dart';
|
||||||
|
import '../../../../../../components/loader/loader_with_text.dart';
|
||||||
|
import '../../widgets/printer_card.dart';
|
||||||
|
import 'setting_printer_form.dart';
|
||||||
|
|
||||||
|
class SettingPrinterTicket extends StatefulWidget {
|
||||||
|
const SettingPrinterTicket({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingPrinterTicket> createState() => _SettingPrinterTicketState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingPrinterTicketState extends State<SettingPrinterTicket> {
|
||||||
|
bool isEdit = false;
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
const PrinterLoaderEvent.getByCode('ticket'),
|
||||||
|
);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: AppColor.background,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
BlocBuilder<PrinterLoaderBloc, PrinterLoaderState>(
|
||||||
|
builder: (context, state) {
|
||||||
|
if (state.isFetching) {
|
||||||
|
return const Center(child: LoaderWithText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.printer.code == '') {
|
||||||
|
return SettingPrinterForm(
|
||||||
|
code: 'ticket',
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('ticket'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.failureOption.fold(
|
||||||
|
() => isEdit
|
||||||
|
? SettingPrinterForm(
|
||||||
|
code: 'ticket',
|
||||||
|
printer: state.printer,
|
||||||
|
onCancel: () {
|
||||||
|
setState(() {
|
||||||
|
isEdit = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('ticket'),
|
||||||
|
);
|
||||||
|
setState(() {
|
||||||
|
isEdit = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: PrinterCard(
|
||||||
|
printer: state.printer,
|
||||||
|
onEdit: () {
|
||||||
|
setState(() {
|
||||||
|
isEdit = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(f) => f.maybeMap(
|
||||||
|
orElse: () => ErrorCard(
|
||||||
|
title: 'Error',
|
||||||
|
message: 'Terjadi Kesalahan',
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
empty: (value) => SettingPrinterForm(
|
||||||
|
code: 'ticket',
|
||||||
|
onSuccess: () {
|
||||||
|
context.read<PrinterLoaderBloc>().add(
|
||||||
|
PrinterLoaderEvent.getByCode('ticket'),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,8 +2,11 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../../../components/page/page_title.dart';
|
import '../../../../../components/page/page_title.dart';
|
||||||
import '../../../../../components/tab/custom_tabbar.dart';
|
import '../../../../../components/tab/custom_tabbar.dart';
|
||||||
|
import 'printer/setting_printer_bar.dart';
|
||||||
import 'printer/setting_printer_checker.dart';
|
import 'printer/setting_printer_checker.dart';
|
||||||
|
import 'printer/setting_printer_kitchen.dart';
|
||||||
import 'printer/setting_printer_receipt.dart';
|
import 'printer/setting_printer_receipt.dart';
|
||||||
|
import 'printer/setting_printer_ticket.dart';
|
||||||
|
|
||||||
class SettingPrinterSection extends StatelessWidget {
|
class SettingPrinterSection extends StatelessWidget {
|
||||||
const SettingPrinterSection({super.key});
|
const SettingPrinterSection({super.key});
|
||||||
@ -29,9 +32,9 @@ class SettingPrinterSection extends StatelessWidget {
|
|||||||
tabViews: [
|
tabViews: [
|
||||||
SettingPrinterReceipt(),
|
SettingPrinterReceipt(),
|
||||||
SettingPrinterChecker(),
|
SettingPrinterChecker(),
|
||||||
Text('Kitchen Printer'),
|
SettingPrinterKitchen(),
|
||||||
Text('Bar Printer'),
|
SettingPrinterBar(),
|
||||||
Text('Tiket Printer'),
|
SettingPrinterTicket(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user