Compare commits
2 Commits
558828f3e0
...
442ef06147
Author | SHA1 | Date | |
---|---|---|---|
442ef06147 | |||
606a0d708a |
358
assets/highlighting/cpp.json
Normal file
358
assets/highlighting/cpp.json
Normal file
@ -0,0 +1,358 @@
|
|||||||
|
{
|
||||||
|
"name": "C++",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"fileTypes": ["cpp", "hpp", "cc", "h"],
|
||||||
|
"scopeName": "source.cpp",
|
||||||
|
|
||||||
|
"foldingStartMarker": "\\{\\s*$",
|
||||||
|
"foldingStopMarker": "^\\s*\\}",
|
||||||
|
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "meta.preprocessor.script.cpp",
|
||||||
|
"match": "^\\s*#\\s*(include|define|if|ifdef|ifndef|else|endif|pragma)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meta.declaration.cpp",
|
||||||
|
"begin": "^\\w*\\b(namespace|class|struct|enum|typedef|template)\\b",
|
||||||
|
"beginCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "keyword.other.declaration.cpp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"end": "(\\{|;)",
|
||||||
|
"endCaptures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.terminator.cpp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#strings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.other.cpp",
|
||||||
|
"match": "\\b(public|private|protected|virtual|override|final)\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#punctuation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#annotations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#keywords"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#constants-and-special-vars"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#operators"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#strings"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"repository": {
|
||||||
|
"comments": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "comment.block.empty.cpp",
|
||||||
|
"match": "/\\*\\*/",
|
||||||
|
"captures": {
|
||||||
|
"0": {
|
||||||
|
"name": "punctuation.definition.comment.cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments-doc-oldschool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments-doc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments-inline"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"comments-doc-oldschool": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "comment.block.documentation.cpp",
|
||||||
|
"begin": "/\\*\\*",
|
||||||
|
"end": "\\*/",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#comments-doc-oldschool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments-block"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"comments-doc": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "comment.block.documentation.cpp",
|
||||||
|
"begin": "///",
|
||||||
|
"while": "^\\s*///",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#comments-inline"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"comments-inline": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#comments-block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": "(//.*)$",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "comment.line.double-slash.cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"comments-block": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "comment.block.cpp",
|
||||||
|
"begin": "/\\*",
|
||||||
|
"end": "\\*/",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#comments-block"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "storage.type.annotation.cpp",
|
||||||
|
"match": "__attribute__\\(\\w+\\)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"constants-and-special-vars": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.language.cpp",
|
||||||
|
"match": "\\b(true|false|nullptr)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "variable.language.cpp",
|
||||||
|
"match": "\\b(this|super)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "constant.numeric.cpp",
|
||||||
|
"match": "\\b((0(x|X)[0-9a-fA-F]+)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#class-identifier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#function-identifier"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class-identifier": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "\\b(bool|int|char|double|float|long|short|signed|unsigned|void)\\b",
|
||||||
|
"name": "storage.type.primitive.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"begin": "(\\b[A-Z]\\w*\\b)",
|
||||||
|
"end": "(?!<)",
|
||||||
|
"beginCaptures": {
|
||||||
|
"1": {
|
||||||
|
"name": "support.class.cpp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#type-args"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"function-identifier": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "\\b([a-z_][a-zA-Z0-9_]*)\\s*\\(",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "entity.name.function.cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type-args": {
|
||||||
|
"begin": "(<)",
|
||||||
|
"end": "(>)",
|
||||||
|
"beginCaptures": {
|
||||||
|
"1": {
|
||||||
|
"name": "other.source.cpp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"endCaptures": {
|
||||||
|
"1": {
|
||||||
|
"name": "other.source.cpp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#class-identifier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.declaration.cpp",
|
||||||
|
"match": "extends"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#comments"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"keywords": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "keyword.control.cpp",
|
||||||
|
"match": "\\b(if|else|for|while|do|switch|case|break|continue|goto|return)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.operator.cpp",
|
||||||
|
"match": "\\b(sizeof|typeid|decltype|new|delete)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.control.try.cpp",
|
||||||
|
"match": "\\b(try|catch|throw)\\b"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.control.cpp",
|
||||||
|
"match": "\\b(static|inline|virtual|override|const|volatile|explicit|friend|constexpr)\\b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"operators": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "keyword.operator.comparison.cpp",
|
||||||
|
"match": "(==|!=|<=?|>=?)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.operator.arithmetic.cpp",
|
||||||
|
"match": "(\\+|\\-|\\*|\\/|%)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.operator.assignment.cpp",
|
||||||
|
"match": "(=|\\+=|-=|\\*=|/=|%=)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.operator.logical.cpp",
|
||||||
|
"match": "(\\&\\&|\\|\\||!)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "keyword.operator.bitwise.cpp",
|
||||||
|
"match": "(<<|>>|\\&|\\||\\^|~)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"string-interp": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"match": "\\$([a-zA-Z0-9_]+)",
|
||||||
|
"captures": {
|
||||||
|
"1": {
|
||||||
|
"name": "variable.parameter.cpp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.interpolated.expression.cpp",
|
||||||
|
"begin": "\\$\\{",
|
||||||
|
"end": "\\}",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#constants-and-special-vars",
|
||||||
|
"name": "variable.parameter.cpp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"include": "#strings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "variable.parameter.cpp",
|
||||||
|
"match": "[a-zA-Z0-9_]+"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "constant.character.escape.cpp",
|
||||||
|
"match": "\\\\."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"strings": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "string.quoted.double.cpp",
|
||||||
|
"begin": "\"",
|
||||||
|
"end": "\"",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.character.escape.cpp",
|
||||||
|
"match": "\\\\."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "string.quoted.single.cpp",
|
||||||
|
"begin": "'",
|
||||||
|
"end": "'",
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "constant.character.escape.cpp",
|
||||||
|
"match": "\\\\."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"punctuation": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "punctuation.comma.cpp",
|
||||||
|
"match": ","
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "punctuation.terminator.cpp",
|
||||||
|
"match": ";"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,11 +117,13 @@ class _ChatListState extends State<ChatList> {
|
|||||||
final ctrl = ChatEventController();
|
final ctrl = ChatEventController();
|
||||||
await ctrl.initialize();
|
await ctrl.initialize();
|
||||||
final messages = await ctrl.src.getLastInAllChannels();
|
final messages = await ctrl.src.getLastInAllChannels();
|
||||||
setState(() {
|
if (mounted) {
|
||||||
_lastMessages = messages
|
setState(() {
|
||||||
.map((k, v) => MapEntry(k, v.firstOrNull))
|
_lastMessages = messages
|
||||||
.cast<int, LocalMessageEventTableData>();
|
.map((k, v) => MapEntry(k, v.firstOrNull))
|
||||||
});
|
.cast<int, LocalMessageEventTableData>();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -273,116 +273,69 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
),
|
),
|
||||||
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
|
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: DefaultTabController(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
length: 2,
|
||||||
children: [
|
child: AppTheme.isLargeScreen(context)
|
||||||
Expanded(
|
? Row(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: _PostEditorTextField(
|
||||||
children: [
|
focusNode: _contentFocusNode,
|
||||||
Container(
|
controller: _editorController,
|
||||||
padding: const EdgeInsets.symmetric(
|
onUpdate: () => setState(() {}),
|
||||||
horizontal: 16,
|
),
|
||||||
vertical: 8,
|
),
|
||||||
),
|
const VerticalDivider(width: 0.3, thickness: 0.3)
|
||||||
child: TextField(
|
.paddingSymmetric(horizontal: 16),
|
||||||
maxLines: null,
|
Expanded(
|
||||||
autofocus: true,
|
child: SingleChildScrollView(
|
||||||
autocorrect: true,
|
padding:
|
||||||
keyboardType: TextInputType.multiline,
|
const EdgeInsets.only(top: 12, bottom: 64),
|
||||||
controller:
|
child: MarkdownTextContent(
|
||||||
_editorController.contentController,
|
isAutoWarp: _editorController.mode.value == 0,
|
||||||
focusNode: _contentFocusNode,
|
content:
|
||||||
decoration: InputDecoration.collapsed(
|
_editorController.contentController.text,
|
||||||
hintText: 'postContentPlaceholder'.tr,
|
parentId: 'post-editor-preview',
|
||||||
),
|
).paddingOnly(right: 16),
|
||||||
onTapOutside: (_) => FocusManager
|
),
|
||||||
.instance.primaryFocus
|
),
|
||||||
?.unfocus(),
|
],
|
||||||
),
|
)
|
||||||
),
|
: Column(
|
||||||
const Gap(120)
|
children: [
|
||||||
|
TabBar(
|
||||||
|
tabs: [
|
||||||
|
const Tab(icon: Icon(Icons.edit)),
|
||||||
|
const Tab(icon: Icon(Icons.preview)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
Obx(() {
|
child: TabBarView(
|
||||||
final textStyle = TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurface
|
|
||||||
.withOpacity(0.75),
|
|
||||||
);
|
|
||||||
final showFactors = [
|
|
||||||
_editorController.isRestoreFromLocal.value,
|
|
||||||
_editorController.lastSaveTime.value != null,
|
|
||||||
];
|
|
||||||
final doShow = showFactors.any((x) => x);
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 4,
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
if (showFactors[0])
|
_PostEditorTextField(
|
||||||
Text('postRestoreFromLocal'.tr,
|
focusNode: _contentFocusNode,
|
||||||
style: textStyle)
|
controller: _editorController,
|
||||||
.paddingOnly(right: 4),
|
onUpdate: () => setState(() {}),
|
||||||
if (showFactors[0])
|
),
|
||||||
InkWell(
|
SingleChildScrollView(
|
||||||
child: Text('clear'.tr, style: textStyle),
|
padding: const EdgeInsets.only(
|
||||||
onTap: () {
|
top: 12,
|
||||||
_editorController.localClear();
|
bottom: 64,
|
||||||
_editorController.currentClear();
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
if (showFactors.where((x) => x).length > 1)
|
|
||||||
Text(
|
|
||||||
'·',
|
|
||||||
style: textStyle,
|
|
||||||
).paddingSymmetric(horizontal: 8),
|
|
||||||
if (showFactors[1])
|
|
||||||
Text(
|
|
||||||
'postAutoSaveAt'.trParams({
|
|
||||||
'date': DateFormat('HH:mm:ss').format(
|
|
||||||
_editorController.lastSaveTime.value ??
|
|
||||||
DateTime.now(),
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
style: textStyle,
|
|
||||||
),
|
),
|
||||||
|
child: MarkdownTextContent(
|
||||||
|
isAutoWarp:
|
||||||
|
_editorController.mode.value == 0,
|
||||||
|
content: _editorController
|
||||||
|
.contentController.text,
|
||||||
|
parentId: 'post-editor-preview',
|
||||||
|
).paddingOnly(left: 16, right: 16),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
.animate(
|
],
|
||||||
key: const Key('post-editor-hint-animation'),
|
|
||||||
target: doShow ? 1 : 0,
|
|
||||||
)
|
|
||||||
.fade(curve: Curves.easeInOut, duration: 300.ms);
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (AppTheme.isLargeScreen(context))
|
|
||||||
const VerticalDivider(width: 0.3, thickness: 0.3)
|
|
||||||
.paddingSymmetric(
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
if (AppTheme.isLargeScreen(context))
|
|
||||||
Expanded(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: MarkdownTextContent(
|
|
||||||
isAutoWarp: _editorController.mode.value == 0,
|
|
||||||
content: _editorController.contentController.text,
|
|
||||||
parentId: 'post-editor-preview',
|
|
||||||
).paddingOnly(top: 12, right: 16),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Material(
|
Material(
|
||||||
@ -391,6 +344,26 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Divider(thickness: 0.3, height: 0.3),
|
const Divider(thickness: 0.3, height: 0.3),
|
||||||
|
SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: MarkdownToolbar(
|
||||||
|
width: 38,
|
||||||
|
height: 38,
|
||||||
|
iconSize: 20,
|
||||||
|
spacing: 8,
|
||||||
|
hideImage: true,
|
||||||
|
useIncludedTextField: false,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
|
iconColor: Theme.of(context).colorScheme.onSurface,
|
||||||
|
controller: _editorController.contentController,
|
||||||
|
focusNode: _contentFocusNode,
|
||||||
|
borderRadius:
|
||||||
|
const BorderRadius.all(Radius.circular(20)),
|
||||||
|
).paddingSymmetric(horizontal: 12),
|
||||||
|
),
|
||||||
|
).paddingOnly(top: 12),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 56,
|
height: 56,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
@ -520,7 +493,7 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
top: -4,
|
top: -4,
|
||||||
end: -6,
|
end: -6,
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.preview),
|
child: const Icon(Icons.wallpaper),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
@ -547,18 +520,6 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
_editorController.editPublishDate(context);
|
_editorController.editPublishDate(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
MarkdownToolbar(
|
|
||||||
hideImage: true,
|
|
||||||
useIncludedTextField: false,
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.surface,
|
|
||||||
iconColor: Theme.of(context).colorScheme.onSurface,
|
|
||||||
controller: _editorController.contentController,
|
|
||||||
focusNode: _contentFocusNode,
|
|
||||||
borderRadius:
|
|
||||||
const BorderRadius.all(Radius.circular(20)),
|
|
||||||
width: 40,
|
|
||||||
).paddingSymmetric(horizontal: 2),
|
|
||||||
],
|
],
|
||||||
).paddingSymmetric(horizontal: 6, vertical: 8),
|
).paddingSymmetric(horizontal: 6, vertical: 8),
|
||||||
),
|
),
|
||||||
@ -578,3 +539,102 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _PostEditorTextField extends StatelessWidget {
|
||||||
|
final FocusNode focusNode;
|
||||||
|
final PostEditorController controller;
|
||||||
|
final Function onUpdate;
|
||||||
|
|
||||||
|
const _PostEditorTextField({
|
||||||
|
super.key,
|
||||||
|
required this.focusNode,
|
||||||
|
required this.controller,
|
||||||
|
required this.onUpdate,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ListView(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 16,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
child: TextField(
|
||||||
|
maxLines: null,
|
||||||
|
autofocus: true,
|
||||||
|
autocorrect: true,
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
controller: controller.contentController,
|
||||||
|
focusNode: focusNode,
|
||||||
|
decoration: InputDecoration.collapsed(
|
||||||
|
hintText: 'postContentPlaceholder'.tr,
|
||||||
|
),
|
||||||
|
onTapOutside: (_) =>
|
||||||
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(120)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Obx(() {
|
||||||
|
final textStyle = TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
|
||||||
|
);
|
||||||
|
final showFactors = [
|
||||||
|
controller.isRestoreFromLocal.value,
|
||||||
|
controller.lastSaveTime.value != null,
|
||||||
|
];
|
||||||
|
final doShow = showFactors.any((x) => x);
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 4,
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (showFactors[0])
|
||||||
|
Text('postRestoreFromLocal'.tr, style: textStyle)
|
||||||
|
.paddingOnly(right: 4),
|
||||||
|
if (showFactors[0])
|
||||||
|
InkWell(
|
||||||
|
child: Text('clear'.tr, style: textStyle),
|
||||||
|
onTap: () {
|
||||||
|
controller.localClear();
|
||||||
|
controller.currentClear();
|
||||||
|
onUpdate();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (showFactors.where((x) => x).length > 1)
|
||||||
|
Text(
|
||||||
|
'·',
|
||||||
|
style: textStyle,
|
||||||
|
).paddingSymmetric(horizontal: 8),
|
||||||
|
if (showFactors[1])
|
||||||
|
Text(
|
||||||
|
'postAutoSaveAt'.trParams({
|
||||||
|
'date': DateFormat('HH:mm:ss').format(
|
||||||
|
controller.lastSaveTime.value ?? DateTime.now(),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
style: textStyle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.animate(
|
||||||
|
key: const Key('post-editor-hint-animation'),
|
||||||
|
target: doShow ? 1 : 0,
|
||||||
|
)
|
||||||
|
.fade(curve: Curves.easeInOut, duration: 300.ms);
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,6 +49,7 @@ class RootShell extends StatelessWidget {
|
|||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: rootScaffoldKey,
|
key: rootScaffoldKey,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
bottomNavigationBar: showBottomNavigation
|
bottomNavigationBar: showBottomNavigation
|
||||||
? AppNavigationBottom(
|
? AppNavigationBottom(
|
||||||
initialIndex: destNames.indexOf(routeName ?? 'page'),
|
initialIndex: destNames.indexOf(routeName ?? 'page'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user