forked from eatvio/eatvio_app
feat(md): Issue-746
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:eatvio_app/common/widgets/markdown_editor.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
@@ -54,6 +55,8 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
final nameController = TextEditingController();
|
||||
final descriptionController = TextEditingController();
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<MarkdownEditorState> _mdKey = GlobalKey<MarkdownEditorState>();
|
||||
bool _mdToolbarVisible = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -92,6 +95,8 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: appTheme.gray100,
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||
floatingActionButton: _mdToolbarVisible && _mdKey.currentState != null ? _mdKey.currentState!.buildToolbar(context) : null,
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text(
|
||||
@@ -122,20 +127,19 @@ class _CreateDietScreenContentState extends State<CreateDietScreenContent> {
|
||||
),
|
||||
if (state.dietNameError != null) ...[const SizedBox(height: 4), ValidationErrorWidget(error: state.dietNameError ?? '')],
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 132,
|
||||
child: CustomTextFormField(
|
||||
hasError: state.dietDescriptionError != null,
|
||||
controller: descriptionController,
|
||||
textAlignVertical: TextAlignVertical.top,
|
||||
maxLines: null,
|
||||
minLines: null,
|
||||
expands: true,
|
||||
hintText: s.enter_diet_description,
|
||||
onChanged: (value) {
|
||||
context.read<CreateDietCubit>().setDetails(value);
|
||||
},
|
||||
),
|
||||
MarkdownEditor(
|
||||
key: _mdKey,
|
||||
initialText: descriptionController.text,
|
||||
hintText: s.enter_diet_description,
|
||||
hasError: state.dietDescriptionError != null,
|
||||
minLines: 6,
|
||||
maxLines: 8,
|
||||
showInlineToolbar: false,
|
||||
onToolbarVisibilityChanged: (v) => setState(() => _mdToolbarVisible = v),
|
||||
onChanged: (value) {
|
||||
descriptionController.text = value;
|
||||
context.read<CreateDietCubit>().setDetails(value);
|
||||
},
|
||||
),
|
||||
if (state.dietDescriptionError != null) ...[const SizedBox(height: 4), ValidationErrorWidget(error: state.dietDescriptionError ?? '')],
|
||||
const SizedBox(height: 12),
|
||||
|
||||
Reference in New Issue
Block a user