printer form, bluetooth
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../../../common/data/printer_data.dart';
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../../components/button/button.dart';
|
||||
import '../../../../../../components/dialog/dialog.dart';
|
||||
import '../../../../../../components/field/field.dart';
|
||||
import '../../../../../../components/spaces/space.dart';
|
||||
|
||||
class SettingPrinterForm extends StatelessWidget {
|
||||
final String code;
|
||||
const SettingPrinterForm({super.key, required this.code});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.white,
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppDropdownSearch<String>(
|
||||
label: 'Tipe',
|
||||
hintText: 'Printer Tipe',
|
||||
items: printerTypes,
|
||||
itemAsString: (value) => value,
|
||||
),
|
||||
SpaceHeight(12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: AppElevatedButton.outlined(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
PrinterBluetoothDialog(onSelected: (value) {}),
|
||||
);
|
||||
},
|
||||
label: 'Cari',
|
||||
),
|
||||
),
|
||||
SpaceHeight(12),
|
||||
AppTextFormField(label: 'Nama Printer'),
|
||||
SpaceHeight(12),
|
||||
AppDropdownSearch<String>(
|
||||
label: 'Kertas',
|
||||
hintText: 'Kertas Tipe',
|
||||
items: paperTypes,
|
||||
itemAsString: (value) => "$value mm",
|
||||
),
|
||||
SpaceHeight(20),
|
||||
AppElevatedButton.filled(onPressed: () {}, label: 'Simpan'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../../../common/theme/theme.dart';
|
||||
import 'setting_printer_form.dart';
|
||||
|
||||
class SettingPrinterReceipt extends StatelessWidget {
|
||||
const SettingPrinterReceipt({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.background,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(children: [SettingPrinterForm(code: 'receipt')]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../components/page/page_title.dart';
|
||||
import '../../../../../components/tab/custom_tabbar.dart';
|
||||
import 'printer/setting_printer_receipt.dart';
|
||||
|
||||
class SettingPrinterSection extends StatelessWidget {
|
||||
const SettingPrinterSection({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
PageTitle(
|
||||
isBack: false,
|
||||
title: 'Printer',
|
||||
subtitle: 'Kelola printer untuk cetak struk',
|
||||
),
|
||||
Expanded(
|
||||
child: CustomTabBar(
|
||||
tabTitles: [
|
||||
'Receipt Printer',
|
||||
'Checker Printer',
|
||||
'Kitchen Printer',
|
||||
'Bar Printer',
|
||||
'Tiket Printer',
|
||||
],
|
||||
tabViews: [
|
||||
SettingPrinterReceipt(),
|
||||
Text('Checker Printer'),
|
||||
Text('Kitchen Printer'),
|
||||
Text('Bar Printer'),
|
||||
Text('Tiket Printer'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,42 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../application/printer/printer_bloc.dart';
|
||||
import '../../../../../common/theme/theme.dart';
|
||||
import '../../../../../injection.dart';
|
||||
import 'sections/setting_printer_section.dart';
|
||||
import 'widgets/setting_left_panel.dart';
|
||||
|
||||
@RoutePage()
|
||||
class SettingPage extends StatelessWidget {
|
||||
class SettingPage extends StatelessWidget implements AutoRouteWrapper {
|
||||
const SettingPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Center(child: Text('Setting Page'));
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.white,
|
||||
body: BlocBuilder<PrinterBloc, PrinterState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: SettingLeftPanel(state: state)),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: switch (state.index) {
|
||||
0 => SettingPrinterSection(),
|
||||
1 => Container(),
|
||||
_ => Container(),
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget wrappedRoute(BuildContext context) =>
|
||||
BlocProvider(create: (context) => getIt<PrinterBloc>(), child: this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../../../application/printer/printer_bloc.dart';
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../components/page/page_title.dart';
|
||||
import 'setting_tile.dart';
|
||||
|
||||
class SettingLeftPanel extends StatelessWidget {
|
||||
final PrinterState state;
|
||||
const SettingLeftPanel({super.key, required this.state});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: AppColor.white,
|
||||
child: Column(
|
||||
children: [
|
||||
PageTitle(
|
||||
title: 'Pengaturan',
|
||||
subtitle: 'Kelola pengaturan aplikasi',
|
||||
isBack: false,
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
SettingTile(
|
||||
index: 0,
|
||||
currentIndex: state.index,
|
||||
title: 'Printer',
|
||||
subtitle: 'Kelola printer',
|
||||
icon: Icons.print_outlined,
|
||||
onTap: () => context.read<PrinterBloc>().add(
|
||||
PrinterEvent.indexChanged(0),
|
||||
),
|
||||
),
|
||||
SettingTile(
|
||||
index: 1,
|
||||
currentIndex: state.index,
|
||||
title: 'Sinkronisasi',
|
||||
subtitle: 'Sinkronisasi data',
|
||||
icon: Icons.sync_outlined,
|
||||
onTap: () => context.read<PrinterBloc>().add(
|
||||
PrinterEvent.indexChanged(1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../../common/theme/theme.dart';
|
||||
import '../../../../../components/spaces/space.dart';
|
||||
|
||||
class SettingTile extends StatelessWidget {
|
||||
final int index;
|
||||
final int currentIndex;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final IconData icon;
|
||||
final Function() onTap;
|
||||
|
||||
const SettingTile({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.icon,
|
||||
required this.onTap,
|
||||
required this.index,
|
||||
required this.currentIndex,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: currentIndex == index
|
||||
? AppColor.primary
|
||||
: Colors.transparent,
|
||||
width: 4.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 24.0,
|
||||
color: currentIndex == index
|
||||
? AppColor.primary
|
||||
: AppColor.textSecondary,
|
||||
),
|
||||
const SpaceWidth(12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
SpaceHeight(4.0),
|
||||
Text(
|
||||
subtitle,
|
||||
style: AppStyle.md.copyWith(color: AppColor.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user