create table
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../../../application/table/table_form/table_form_bloc.dart';
|
||||
import '../../button/button.dart';
|
||||
import '../../field/field.dart';
|
||||
import '../../spaces/space.dart';
|
||||
import '../dialog.dart';
|
||||
|
||||
class TableCreateDialog extends StatelessWidget {
|
||||
const TableCreateDialog({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<TableFormBloc, TableFormState>(
|
||||
builder: (context, state) {
|
||||
return CustomModalDialog(
|
||||
title: 'Tambah Meja',
|
||||
subtitle: 'Silahkan isi data meja',
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
vertical: 24.0,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
AppTextFormField(
|
||||
label: 'Nama Meja',
|
||||
onChanged: (value) {
|
||||
context.read<TableFormBloc>().add(
|
||||
TableFormEvent.nameChanged(value),
|
||||
);
|
||||
},
|
||||
),
|
||||
SpaceHeight(16),
|
||||
AppTextFormField(
|
||||
label: 'Kapasitas',
|
||||
keyboardType: TextInputType.number,
|
||||
onChanged: (value) {
|
||||
context.read<TableFormBloc>().add(
|
||||
TableFormEvent.capacityChanged(value),
|
||||
);
|
||||
},
|
||||
),
|
||||
SpaceHeight(24),
|
||||
AppElevatedButton.filled(
|
||||
onPressed: () {
|
||||
context.read<TableFormBloc>().add(
|
||||
const TableFormEvent.created(),
|
||||
);
|
||||
},
|
||||
label: "Simpan",
|
||||
isLoading: state.isCreating,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../common/theme/theme.dart';
|
||||
import '../../../domain/auth/auth.dart';
|
||||
import '../../../domain/table/table.dart';
|
||||
|
||||
class AppFlushbar {
|
||||
static void showSuccess(BuildContext context, String message) {
|
||||
@@ -50,4 +51,18 @@ class AppFlushbar {
|
||||
unexpectedError: (value) => 'Terjadi kesalahan, silahkan coba lagi',
|
||||
),
|
||||
);
|
||||
|
||||
static void showTableFailureToast(
|
||||
BuildContext context,
|
||||
TableFailure failure,
|
||||
) => showError(
|
||||
context,
|
||||
failure.map(
|
||||
serverError: (value) => value.failure.toStringFormatted(context),
|
||||
dynamicErrorMessage: (value) => value.erroMessage,
|
||||
unexpectedError: (value) => 'Terjadi kesalahan, silahkan coba lagi',
|
||||
empty: (value) => 'Tidak ada data',
|
||||
localStorageError: (value) => 'Terjadi kesalahan, silahkan coba lagi',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user