@@ -17,64 +17,14 @@ class MyApp extends StatelessWidget {
17
17
}
18
18
}
19
19
20
- class HomeScreen extends StatelessWidget {
20
+ class HomeScreen extends StatefulWidget {
21
21
const HomeScreen ({Key ? key}) : super (key: key);
22
22
23
23
@override
24
- Widget build (BuildContext context) {
25
- return Scaffold (
26
- appBar: AppBar (
27
- title: const Text ("Home Screen" ),
28
- ),
29
- body: Center (
30
- child: Column (
31
- mainAxisAlignment: MainAxisAlignment .center,
32
- children: [
33
- MaterialButton (
34
- onPressed: () {
35
- Navigator .push (context,
36
- MaterialPageRoute (builder: (_) => const EditorScreen ()));
37
- },
38
- color: Colors .blue,
39
- child: const Text (
40
- "Editor Screen 1" ,
41
- style: TextStyle (
42
- color: Colors .white,
43
- ),
44
- ),
45
- ),
46
- const SizedBox (height: 10 ),
47
- MaterialButton (
48
- onPressed: () {
49
- Navigator .push (
50
- context,
51
- MaterialPageRoute (
52
- builder: (_) => const EditorTestPreviewUnfocused ()));
53
- },
54
- color: Colors .blue,
55
- child: const Text (
56
- "Editor Screen 2" ,
57
- style: TextStyle (
58
- color: Colors .white,
59
- ),
60
- ),
61
- ),
62
- ],
63
- ),
64
- ),
65
- );
66
- }
67
- }
68
-
69
- // HomeScreen Editor
70
- class EditorScreen extends StatefulWidget {
71
- const EditorScreen ({Key ? key}) : super (key: key);
72
-
73
- @override
74
- _EditorScreenState createState () => _EditorScreenState ();
24
+ State <HomeScreen > createState () => _HomeScreenState ();
75
25
}
76
26
77
- class _EditorScreenState extends State <EditorScreen > {
27
+ class _HomeScreenState extends State <HomeScreen > {
78
28
final TextEditingController _controller = TextEditingController ();
79
29
80
30
@override
@@ -87,114 +37,41 @@ class _EditorScreenState extends State<EditorScreen> {
87
37
Widget build (BuildContext context) {
88
38
return Scaffold (
89
39
appBar: AppBar (
90
- title: const Text ("Markdown Editor" ),
91
- actions: [
92
- IconButton (
93
- onPressed: () {
94
- Navigator .push (
95
- context,
96
- MaterialPageRoute (
97
- builder: (_) => SecondScreen (
98
- data: _controller.text,
99
- ),
100
- ),
101
- );
40
+ title: const Text ("Home Screen" ),
41
+ ),
42
+ body: Column (
43
+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
44
+ children: [
45
+ MarkdownFormField (
46
+ controller: _controller,
47
+ enableToolBar: true ,
48
+ emojiConvert: true ,
49
+ autoCloseAfterSelectEmoji: false ,
50
+ // maxLines: 10,
51
+ // minLines: 1,
52
+ // expands: true,
53
+ onChanged: (s) {
54
+ setState (() {});
102
55
},
103
- icon: const Icon (Icons .view_compact),
104
56
),
105
- ],
106
- ),
107
- body: SafeArea (
108
- child: Column (
109
- children: [
110
- Expanded (
111
- child: MarkdownFormField (
112
- controller: _controller,
113
- enableToolBar: true ,
114
- emojiConvert: true ,
115
- autoCloseAfterSelectEmoji: false ,
116
- ),
117
- ),
118
- ],
119
- ),
120
- ),
121
- );
122
- }
123
- }
124
-
125
- class SecondScreen extends StatelessWidget {
126
- const SecondScreen ({Key ? key, required this .data}) : super (key: key);
127
-
128
- final String data;
129
-
130
- @override
131
- Widget build (BuildContext context) {
132
- return Scaffold (
133
- appBar: AppBar (
134
- title: const Text ("Markdown Parse" ),
135
- ),
136
- body: MarkdownParse (
137
- data: data,
138
- onTapHastag: (String name, String match) {
139
- // example : #hashtag
140
- // name => hashtag
141
- // match => #hashtag
142
- },
143
- onTapMention: (String name, String match) {
144
- // example : @mention
145
- // name => mention
146
- // match => #mention
147
- },
148
- ),
149
- );
150
- }
151
- }
152
-
153
- // HomeScreen Editor
154
- class EditorTestPreviewUnfocused extends StatefulWidget {
155
- const EditorTestPreviewUnfocused ({Key ? key}) : super (key: key);
156
-
157
- @override
158
- _EditorTestPreviewUnfocusedState createState () =>
159
- _EditorTestPreviewUnfocusedState ();
160
- }
161
-
162
- class _EditorTestPreviewUnfocusedState
163
- extends State <EditorTestPreviewUnfocused > {
164
- final TextEditingController _controller = TextEditingController ();
165
-
166
- @override
167
- void dispose () {
168
- _controller.dispose ();
169
- super .dispose ();
170
- }
171
-
172
- @override
173
- Widget build (BuildContext context) {
174
- return Scaffold (
175
- appBar: AppBar (
176
- title: const Text ("Markdown Editor" ),
177
- ),
178
- body: SafeArea (
179
- child: Column (
180
- children: [
181
- Container (
182
- height: 300 ,
183
- decoration: BoxDecoration (
184
- border: Border .all (color: Colors .black),
185
- borderRadius: BorderRadius .circular (20 ),
186
- ),
187
- child: MarkdownFormField (
188
- controller: _controller,
189
- enableToolBar: true ,
190
- emojiConvert: true ,
191
- autoCloseAfterSelectEmoji: false ,
192
- ),
57
+ SizedBox (
58
+ height: 100 ,
59
+ child: MarkdownParse (
60
+ data: _controller.text,
61
+ selectable: true ,
62
+ onTapHastag: (String name, String match) {
63
+ // example : #hashtag
64
+ // name => hashtag
65
+ // match => #hashtag
66
+ },
67
+ onTapMention: (String name, String match) {
68
+ // example : @mention
69
+ // name => mention
70
+ // match => #mention
71
+ },
193
72
),
194
- const SizedBox (height: 10 ),
195
- TextFormField (),
196
- ],
197
- ),
73
+ ),
74
+ ],
198
75
),
199
76
);
200
77
}
0 commit comments