This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/more-settings
- Loading branch information
Showing
7 changed files
with
214 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
|
||
import 'markdown_text.dart'; | ||
|
||
/// A text field with added functionality for ease of editing | ||
class Editor extends HookWidget { | ||
final TextEditingController? controller; | ||
final FocusNode? focusNode; | ||
final ValueChanged<String>? onSubmitted; | ||
final int? minLines; | ||
final String? labelText; | ||
final bool autofocus; | ||
|
||
/// Whether the editor should be preview the contents | ||
final bool fancy; | ||
final String instanceHost; | ||
|
||
const Editor({ | ||
Key? key, | ||
this.controller, | ||
this.focusNode, | ||
this.onSubmitted, | ||
this.minLines = 5, | ||
this.labelText, | ||
this.fancy = false, | ||
required this.instanceHost, | ||
this.autofocus = false, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final defaultController = useTextEditingController(); | ||
final actualController = controller ?? defaultController; | ||
|
||
if (fancy) { | ||
return Padding( | ||
padding: const EdgeInsets.all(8), | ||
child: MarkdownText( | ||
actualController.text, | ||
instanceHost: instanceHost, | ||
), | ||
); | ||
} | ||
|
||
return TextField( | ||
controller: actualController, | ||
focusNode: focusNode, | ||
autofocus: autofocus, | ||
keyboardType: TextInputType.multiline, | ||
textCapitalization: TextCapitalization.sentences, | ||
onSubmitted: onSubmitted, | ||
maxLines: null, | ||
minLines: minLines, | ||
decoration: InputDecoration(labelText: labelText), | ||
); | ||
} | ||
} |
Oops, something went wrong.