Skip to content

Commit 34175f4

Browse files
committed
See CHANGELOG
1 parent 1c88906 commit 34175f4

File tree

7 files changed

+160
-80
lines changed

7 files changed

+160
-80
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.3.0
4+
5+
- Added feature to create a new note by sharing text with Noteless (#42)
6+
- Adding an attachment to a note now automatically embeds it
7+
- Improved blockquote styling (#44)
8+
- Fixed some bugs
9+
310
## 1.2.1
411

512
- Added Android App Shortcut for creating a new note from the homescreen

android/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
android:icon="@mipmap/ic_launcher">
2222
<activity
2323
android:name=".MainActivity"
24-
android:launchMode="singleTop"
24+
android:launchMode="singleTask"
2525
android:theme="@style/LaunchTheme"
2626
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
2727
android:hardwareAccelerated="true"
@@ -38,11 +38,11 @@
3838
<category android:name="android.intent.category.LAUNCHER"/>
3939
</intent-filter>
4040

41-
<!-- <intent-filter>
41+
<intent-filter>
4242
<action android:name="android.intent.action.SEND" />
4343
<category android:name="android.intent.category.DEFAULT" />
4444
<data android:mimeType="text/*" />
45-
</intent-filter> -->
45+
</intent-filter>
4646
</activity>
4747
</application>
4848
</manifest>

lib/page/edit.dart

Lines changed: 98 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class _EditPageState extends State<EditPage> {
4848

4949
bool _previewEnabled = false;
5050

51+
TextSelection _textSelectionCache;
52+
5153
@override
5254
void initState() {
5355
note = widget.note;
@@ -240,7 +242,12 @@ class _EditPageState extends State<EditPage> {
240242
},
241243
)),
242244
PopupMenuButton<String>(
245+
onCanceled: () {
246+
_rec.selection = _textSelectionCache;
247+
},
243248
onSelected: (String result) async {
249+
_rec.selection = _textSelectionCache;
250+
244251
int divIndex = result.indexOf('.');
245252
if (divIndex == -1) divIndex = result.length;
246253

@@ -279,9 +286,28 @@ class _EditPageState extends State<EditPage> {
279286
}
280287
await file.copy(newFile.path);
281288

282-
note.attachments.add(newFile.path.split('/').last);
289+
final attachmentName = newFile.path.split('/').last;
290+
291+
note.attachments.add(attachmentName);
283292

284293
await file.delete();
294+
295+
int start = _rec.selection.start;
296+
297+
final insert = '![](@attachment/$attachmentName)';
298+
299+
_rec.text = _rec.text.substring(
300+
0,
301+
start,
302+
) +
303+
insert +
304+
_rec.text.substring(
305+
start,
306+
);
307+
308+
_rec.selection = TextSelection(
309+
baseOffset: start,
310+
extentOffset: start + insert.length);
285311
}
286312

287313
break;
@@ -388,100 +414,105 @@ class _EditPageState extends State<EditPage> {
388414
}
389415
PersistentStore.saveNote(note);
390416
},
391-
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
392-
PopupMenuItem<String>(
393-
value: 'favorite',
394-
child: Row(
395-
children: <Widget>[
396-
Icon(
397-
note.favorited ? MdiIcons.starOff : MdiIcons.star,
398-
color: Theme.of(context).colorScheme.onSurface,
399-
),
400-
SizedBox(
401-
width: 8,
402-
),
403-
Text(note.favorited ? 'Unfavorite' : 'Favorite'),
404-
],
405-
),
406-
),
407-
PopupMenuItem<String>(
408-
value: 'pin',
409-
child: Row(
410-
children: <Widget>[
411-
Icon(
412-
note.pinned ? MdiIcons.pinOff : MdiIcons.pin,
413-
color: Theme.of(context).colorScheme.onSurface,
414-
),
415-
SizedBox(
416-
width: 8,
417-
),
418-
Text(note.pinned ? 'Unpin' : 'Pin'),
419-
],
417+
itemBuilder: (BuildContext context) {
418+
_textSelectionCache = _rec.selection;
419+
return <PopupMenuEntry<String>>[
420+
PopupMenuItem<String>(
421+
value: 'favorite',
422+
child: Row(
423+
children: <Widget>[
424+
Icon(
425+
note.favorited ? MdiIcons.starOff : MdiIcons.star,
426+
color: Theme.of(context).colorScheme.onSurface,
427+
),
428+
SizedBox(
429+
width: 8,
430+
),
431+
Text(note.favorited ? 'Unfavorite' : 'Favorite'),
432+
],
433+
),
420434
),
421-
),
422-
for (String attachment in note.attachments)
423435
PopupMenuItem<String>(
424-
value: 'removeAttachment.$attachment',
436+
value: 'pin',
425437
child: Row(
426438
children: <Widget>[
427439
Icon(
428-
MdiIcons.paperclip,
440+
note.pinned ? MdiIcons.pinOff : MdiIcons.pin,
429441
color: Theme.of(context).colorScheme.onSurface,
430442
),
431443
SizedBox(
432444
width: 8,
433445
),
434-
Text(attachment),
446+
Text(note.pinned ? 'Unpin' : 'Pin'),
435447
],
436448
),
437449
),
438-
PopupMenuItem<String>(
439-
value: 'addAttachment',
440-
child: Row(
441-
children: <Widget>[
442-
Icon(
443-
MdiIcons.filePlus,
444-
color: Theme.of(context).colorScheme.onSurface,
445-
),
446-
SizedBox(
447-
width: 8,
450+
for (String attachment in note.attachments)
451+
PopupMenuItem<String>(
452+
value: 'removeAttachment.$attachment',
453+
child: Row(
454+
children: <Widget>[
455+
Icon(
456+
MdiIcons.paperclip,
457+
color: Theme.of(context).colorScheme.onSurface,
458+
),
459+
SizedBox(
460+
width: 8,
461+
),
462+
Flexible(
463+
child: Text(attachment),
464+
),
465+
],
448466
),
449-
Text('Add Attachment'),
450-
],
451-
),
452-
),
453-
for (String tag in note.tags)
467+
),
454468
PopupMenuItem<String>(
455-
value: 'removeTag.$tag',
469+
value: 'addAttachment',
456470
child: Row(
457471
children: <Widget>[
458472
Icon(
459-
MdiIcons.tag,
473+
MdiIcons.filePlus,
460474
color: Theme.of(context).colorScheme.onSurface,
461475
),
462476
SizedBox(
463477
width: 8,
464478
),
465-
Text(tag),
479+
Text('Add Attachment'),
466480
],
467481
),
468482
),
469-
PopupMenuItem<String>(
470-
value: 'addTag',
471-
child: Row(
472-
children: <Widget>[
473-
Icon(
474-
MdiIcons.tagPlus,
475-
color: Theme.of(context).colorScheme.onSurface,
476-
),
477-
SizedBox(
478-
width: 8,
483+
for (String tag in note.tags)
484+
PopupMenuItem<String>(
485+
value: 'removeTag.$tag',
486+
child: Row(
487+
children: <Widget>[
488+
Icon(
489+
MdiIcons.tag,
490+
color: Theme.of(context).colorScheme.onSurface,
491+
),
492+
SizedBox(
493+
width: 8,
494+
),
495+
Text(tag),
496+
],
479497
),
480-
Text('Add Tag'),
481-
],
498+
),
499+
PopupMenuItem<String>(
500+
value: 'addTag',
501+
child: Row(
502+
children: <Widget>[
503+
Icon(
504+
MdiIcons.tagPlus,
505+
color: Theme.of(context).colorScheme.onSurface,
506+
),
507+
SizedBox(
508+
width: 8,
509+
),
510+
Text('Add Tag'),
511+
],
512+
),
482513
),
483-
),
484-
],
514+
];
515+
},
485516
)
486517
],
487518
),

lib/page/note_list.dart

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:package_info/package_info.dart';
1212
import 'package:preferences/preferences.dart';
1313
import 'package:flutter_slidable/flutter_slidable.dart';
1414
import 'package:quick_actions/quick_actions.dart';
15+
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
1516
// import 'package:receive_sharing_intent/receive_sharing_intent.dart';
1617

1718
import 'about.dart';
@@ -33,7 +34,7 @@ class _NoteListPageState extends State<NoteListPage> {
3334
TextEditingController _searchFieldCtrl = TextEditingController();
3435
bool searching = false;
3536

36-
// StreamSubscription _intentDataStreamSubscription;
37+
StreamSubscription _intentDataStreamSubscription;
3738

3839
@override
3940
void initState() {
@@ -62,20 +63,20 @@ class _NoteListPageState extends State<NoteListPage> {
6263
icon: 'ic_shortcut_add'),
6364
]);
6465

65-
/* // For sharing or opening urls/text coming from outside the app while the app is in the memory
66+
// For sharing or opening urls/text coming from outside the app while the app is in the memory
6667
_intentDataStreamSubscription =
6768
ReceiveSharingIntent.getTextStream().listen((String value) {
68-
print('SHARED $value');
69+
handleSharedText(value);
6970
ReceiveSharingIntent.reset();
7071
}, onError: (err) {
7172
print("getLinkStream error: $err");
7273
});
7374

7475
// For sharing or opening urls/text coming from outside the app while the app is closed
7576
ReceiveSharingIntent.getInitialText().then((String value) {
76-
print('SHARED $value');
77+
handleSharedText(value);
7778
ReceiveSharingIntent.reset();
78-
}); */
79+
});
7980
}
8081
});
8182

@@ -84,10 +85,36 @@ class _NoteListPageState extends State<NoteListPage> {
8485

8586
@override
8687
void dispose() {
87-
// _intentDataStreamSubscription.cancel();
88+
_intentDataStreamSubscription.cancel();
8889
super.dispose();
8990
}
9091

92+
handleSharedText(String value) {
93+
if (value == null) return;
94+
95+
showDialog(
96+
context: context,
97+
builder: (context) => AlertDialog(
98+
title: Text('Received text'),
99+
content:
100+
Scrollbar(child: SingleChildScrollView(child: Text(value))),
101+
actions: [
102+
FlatButton(
103+
onPressed: () {
104+
Navigator.of(context).pop();
105+
},
106+
child: Text('Cancel')),
107+
// FlatButton(onPressed: () {}, child: Text('Append to note')),
108+
FlatButton(
109+
onPressed: () {
110+
Navigator.of(context).pop();
111+
createNewNote(value);
112+
},
113+
child: Text('Create new note')),
114+
],
115+
));
116+
}
117+
91118
Future<bool> _onWillPop() async {
92119
if (_selectedNotes.isNotEmpty) {
93120
setState(() {
@@ -953,7 +980,7 @@ class _NoteListPageState extends State<NoteListPage> {
953980
);
954981
}
955982

956-
Future<void> createNewNote() async {
983+
Future<void> createNewNote([String content = '']) async {
957984
Note newNote = Note();
958985
int i = 1;
959986
while (true) {
@@ -986,7 +1013,7 @@ class _NoteListPageState extends State<NoteListPage> {
9861013

9871014
_filterAndSortNotes();
9881015

989-
await PersistentStore.saveNote(newNote, '# ${newNote.title}\n\n');
1016+
await PersistentStore.saveNote(newNote, '# ${newNote.title}\n\n$content');
9901017

9911018
await Navigator.of(context).push(MaterialPageRoute(
9921019
builder: (context) => EditPage(

lib/page/preview.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@ pre {
185185
max-width: 100%;
186186
overflow-x: scroll;
187187
}
188+
189+
blockquote{
190+
padding: 0em 0em 0em .6em;
191+
margin-left: .1em;
192+
border-left: 0.3em solid ${theme.brightness == Brightness.light ? 'lightgrey' : 'grey'};
193+
}
194+
195+
188196
</style>
189197
</head>
190198
<body>

pubspec.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ packages:
384384
url: "https://pub.dartlang.org"
385385
source: hosted
386386
version: "2.1.3"
387+
receive_sharing_intent:
388+
dependency: "direct main"
389+
description:
390+
name: receive_sharing_intent
391+
url: "https://pub.dartlang.org"
392+
source: hosted
393+
version: "1.4.1"
387394
rich_code_editor:
388395
dependency: "direct main"
389396
description:

0 commit comments

Comments
 (0)