♻️ Move the title, description out of the settings sheet
This commit is contained in:
@@ -207,8 +207,6 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder:
|
builder:
|
||||||
(context) => ComposeSettingsSheet(
|
(context) => ComposeSettingsSheet(
|
||||||
titleController: state.titleController,
|
|
||||||
descriptionController: state.descriptionController,
|
|
||||||
visibility: state.visibility,
|
visibility: state.visibility,
|
||||||
tagsController: state.tagsController,
|
tagsController: state.tagsController,
|
||||||
categoriesController: state.categoriesController,
|
categoriesController: state.categoriesController,
|
||||||
@@ -370,14 +368,52 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
// Post content form
|
// Post content form
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: state.titleController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postTitle'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.titleMedium,
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus
|
||||||
|
?.unfocus(),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: state.descriptionController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postDescription'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(
|
||||||
|
8,
|
||||||
|
4,
|
||||||
|
8,
|
||||||
|
12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 3,
|
||||||
|
onTapOutside:
|
||||||
|
(_) =>
|
||||||
|
FocusManager.instance.primaryFocus
|
||||||
|
?.unfocus(),
|
||||||
|
),
|
||||||
// Content field with borderless design
|
// Content field with borderless design
|
||||||
RawKeyboardListener(
|
KeyboardListener(
|
||||||
focusNode: FocusNode(),
|
focusNode: FocusNode(),
|
||||||
onKey:
|
onKeyEvent:
|
||||||
(event) => ComposeLogic.handleKeyPress(
|
(event) => ComposeLogic.handleKeyPress(
|
||||||
event,
|
event,
|
||||||
state,
|
state,
|
||||||
@@ -393,7 +429,11 @@ class PostComposeScreen extends HookConsumerWidget {
|
|||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
hintText: 'postContent'.tr(),
|
hintText: 'postContent'.tr(),
|
||||||
contentPadding: const EdgeInsets.all(8),
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
onTapOutside:
|
onTapOutside:
|
||||||
|
@@ -140,8 +140,6 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder:
|
builder:
|
||||||
(context) => ComposeSettingsSheet(
|
(context) => ComposeSettingsSheet(
|
||||||
titleController: state.titleController,
|
|
||||||
descriptionController: state.descriptionController,
|
|
||||||
visibility: state.visibility,
|
visibility: state.visibility,
|
||||||
tagsController: state.tagsController,
|
tagsController: state.tagsController,
|
||||||
categoriesController: state.categoriesController,
|
categoriesController: state.categoriesController,
|
||||||
@@ -242,10 +240,39 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: state.titleController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postTitle'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 8,
|
||||||
|
horizontal: 8,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.titleMedium,
|
||||||
|
onTapOutside:
|
||||||
|
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: state.descriptionController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'postDescription'.tr(),
|
||||||
|
border: InputBorder.none,
|
||||||
|
isCollapsed: true,
|
||||||
|
contentPadding: const EdgeInsets.fromLTRB(8, 4, 8, 12),
|
||||||
|
),
|
||||||
|
style: theme.textTheme.bodyMedium,
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 3,
|
||||||
|
onTapOutside:
|
||||||
|
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: RawKeyboardListener(
|
child: KeyboardListener(
|
||||||
focusNode: FocusNode(),
|
focusNode: FocusNode(),
|
||||||
onKey:
|
onKeyEvent:
|
||||||
(event) => _handleKeyPress(
|
(event) => _handleKeyPress(
|
||||||
event,
|
event,
|
||||||
state,
|
state,
|
||||||
@@ -454,7 +481,7 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
flex: showPreview.value ? 1 : 2,
|
flex: showPreview.value ? 1 : 2,
|
||||||
child: buildEditorPane(),
|
child: buildEditorPane(),
|
||||||
),
|
),
|
||||||
const VerticalDivider(),
|
if (showPreview.value) const VerticalDivider(),
|
||||||
if (showPreview.value)
|
if (showPreview.value)
|
||||||
Expanded(child: buildPreviewPane()),
|
Expanded(child: buildPreviewPane()),
|
||||||
],
|
],
|
||||||
@@ -475,7 +502,7 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
// Helper method to handle keyboard shortcuts
|
// Helper method to handle keyboard shortcuts
|
||||||
void _handleKeyPress(
|
void _handleKeyPress(
|
||||||
RawKeyEvent event,
|
KeyEvent event,
|
||||||
ComposeState state,
|
ComposeState state,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
@@ -485,7 +512,9 @@ class ArticleComposeScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
||||||
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
||||||
final isModifierPressed = event.isMetaPressed || event.isControlPressed;
|
final isModifierPressed =
|
||||||
|
HardwareKeyboard.instance.isMetaPressed ||
|
||||||
|
HardwareKeyboard.instance.isControlPressed;
|
||||||
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
||||||
|
|
||||||
if (isPaste && isModifierPressed) {
|
if (isPaste && isModifierPressed) {
|
||||||
|
@@ -99,8 +99,6 @@ class ChipTagInputField extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ComposeSettingsSheet extends HookWidget {
|
class ComposeSettingsSheet extends HookWidget {
|
||||||
final TextEditingController titleController;
|
|
||||||
final TextEditingController descriptionController;
|
|
||||||
final ValueNotifier<int> visibility;
|
final ValueNotifier<int> visibility;
|
||||||
final VoidCallback? onVisibilityChanged;
|
final VoidCallback? onVisibilityChanged;
|
||||||
final StringTagController tagsController;
|
final StringTagController tagsController;
|
||||||
@@ -108,8 +106,6 @@ class ComposeSettingsSheet extends HookWidget {
|
|||||||
|
|
||||||
const ComposeSettingsSheet({
|
const ComposeSettingsSheet({
|
||||||
super.key,
|
super.key,
|
||||||
required this.titleController,
|
|
||||||
required this.descriptionController,
|
|
||||||
required this.visibility,
|
required this.visibility,
|
||||||
this.onVisibilityChanged,
|
this.onVisibilityChanged,
|
||||||
required this.tagsController,
|
required this.tagsController,
|
||||||
@@ -216,39 +212,6 @@ class ComposeSettingsSheet extends HookWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
children: [
|
children: [
|
||||||
// Title field
|
|
||||||
TextField(
|
|
||||||
controller: titleController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'postTitle'.tr(),
|
|
||||||
hintText: 'postTitle'.tr(),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.all(16),
|
|
||||||
),
|
|
||||||
style: theme.textTheme.titleMedium,
|
|
||||||
onTapOutside:
|
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Description field
|
|
||||||
TextField(
|
|
||||||
controller: descriptionController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'postDescription'.tr(),
|
|
||||||
hintText: 'postDescription'.tr(),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.all(16),
|
|
||||||
),
|
|
||||||
style: theme.textTheme.bodyMedium,
|
|
||||||
maxLines: 3,
|
|
||||||
onTapOutside:
|
|
||||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Tags field
|
// Tags field
|
||||||
TextFieldTags(
|
TextFieldTags(
|
||||||
textfieldTagsController: tagsController,
|
textfieldTagsController: tagsController,
|
||||||
|
@@ -689,7 +689,7 @@ class ComposeLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handleKeyPress(
|
static void handleKeyPress(
|
||||||
RawKeyEvent event,
|
KeyEvent event,
|
||||||
ComposeState state,
|
ComposeState state,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
@@ -701,7 +701,9 @@ class ComposeLogic {
|
|||||||
|
|
||||||
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
final isPaste = event.logicalKey == LogicalKeyboardKey.keyV;
|
||||||
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
final isSave = event.logicalKey == LogicalKeyboardKey.keyS;
|
||||||
final isModifierPressed = event.isMetaPressed || event.isControlPressed;
|
final isModifierPressed =
|
||||||
|
HardwareKeyboard.instance.isMetaPressed ||
|
||||||
|
HardwareKeyboard.instance.isControlPressed;
|
||||||
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
final isSubmit = event.logicalKey == LogicalKeyboardKey.enter;
|
||||||
|
|
||||||
if (isPaste && isModifierPressed) {
|
if (isPaste && isModifierPressed) {
|
||||||
|
@@ -63,6 +63,7 @@ class ComposeToolbar extends HookConsumerWidget {
|
|||||||
|
|
||||||
return Material(
|
return Material(
|
||||||
elevation: 4,
|
elevation: 4,
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerLow,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(maxWidth: 560),
|
constraints: const BoxConstraints(maxWidth: 560),
|
||||||
|
Reference in New Issue
Block a user