parent
7f1b4bd699
commit
ec44d81f7c
9 changed files with 187 additions and 46 deletions
@ -0,0 +1,45 @@ |
||||
import 'dart:convert' show jsonDecode, jsonEncode; |
||||
|
||||
import 'package:flutter/material.dart' show Icons; |
||||
import 'package:flutter/widgets.dart'; |
||||
import 'package:flutter_quill/flutter_quill.dart'; |
||||
|
||||
class TimeStampEmbed extends Embeddable { |
||||
const TimeStampEmbed( |
||||
String value, |
||||
) : super(timeStampType, value); |
||||
|
||||
static const String timeStampType = 'timeStamp'; |
||||
|
||||
static TimeStampEmbed fromDocument(Document document) => |
||||
TimeStampEmbed(jsonEncode(document.toDelta().toJson())); |
||||
|
||||
Document get document => Document.fromJson(jsonDecode(data)); |
||||
} |
||||
|
||||
class TimeStampEmbedBuilderWidget extends EmbedBuilder { |
||||
@override |
||||
String get key => 'timeStamp'; |
||||
|
||||
@override |
||||
String toPlainText(Embed node) { |
||||
return node.value.data; |
||||
} |
||||
|
||||
@override |
||||
Widget build( |
||||
BuildContext context, |
||||
QuillController controller, |
||||
Embed node, |
||||
bool readOnly, |
||||
bool inline, |
||||
TextStyle textStyle, |
||||
) { |
||||
return Row( |
||||
children: [ |
||||
const Icon(Icons.access_time_rounded), |
||||
Text(node.value.data as String), |
||||
], |
||||
); |
||||
} |
||||
} |
Loading…
Reference in new issue