Skip to content

Commit

Permalink
See CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
redsolver committed Sep 20, 2020
1 parent 1c88906 commit 34175f4
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 80 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.3.0

- Added feature to create a new note by sharing text with Noteless (#42)
- Adding an attachment to a note now automatically embeds it
- Improved blockquote styling (#44)
- Fixed some bugs

## 1.2.1

- Added Android App Shortcut for creating a new note from the homescreen
Expand Down
6 changes: 3 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:launchMode="singleTask"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand All @@ -38,11 +38,11 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<!-- <intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter> -->
</intent-filter>
</activity>
</application>
</manifest>
165 changes: 98 additions & 67 deletions lib/page/edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class _EditPageState extends State<EditPage> {

bool _previewEnabled = false;

TextSelection _textSelectionCache;

@override
void initState() {
note = widget.note;
Expand Down Expand Up @@ -240,7 +242,12 @@ class _EditPageState extends State<EditPage> {
},
)),
PopupMenuButton<String>(
onCanceled: () {
_rec.selection = _textSelectionCache;
},
onSelected: (String result) async {
_rec.selection = _textSelectionCache;

int divIndex = result.indexOf('.');
if (divIndex == -1) divIndex = result.length;

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

note.attachments.add(newFile.path.split('/').last);
final attachmentName = newFile.path.split('/').last;

note.attachments.add(attachmentName);

await file.delete();

int start = _rec.selection.start;

final insert = '![](@attachment/$attachmentName)';

_rec.text = _rec.text.substring(
0,
start,
) +
insert +
_rec.text.substring(
start,
);

_rec.selection = TextSelection(
baseOffset: start,
extentOffset: start + insert.length);
}

break;
Expand Down Expand Up @@ -388,100 +414,105 @@ class _EditPageState extends State<EditPage> {
}
PersistentStore.saveNote(note);
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'favorite',
child: Row(
children: <Widget>[
Icon(
note.favorited ? MdiIcons.starOff : MdiIcons.star,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text(note.favorited ? 'Unfavorite' : 'Favorite'),
],
),
),
PopupMenuItem<String>(
value: 'pin',
child: Row(
children: <Widget>[
Icon(
note.pinned ? MdiIcons.pinOff : MdiIcons.pin,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text(note.pinned ? 'Unpin' : 'Pin'),
],
itemBuilder: (BuildContext context) {
_textSelectionCache = _rec.selection;
return <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: 'favorite',
child: Row(
children: <Widget>[
Icon(
note.favorited ? MdiIcons.starOff : MdiIcons.star,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text(note.favorited ? 'Unfavorite' : 'Favorite'),
],
),
),
),
for (String attachment in note.attachments)
PopupMenuItem<String>(
value: 'removeAttachment.$attachment',
value: 'pin',
child: Row(
children: <Widget>[
Icon(
MdiIcons.paperclip,
note.pinned ? MdiIcons.pinOff : MdiIcons.pin,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text(attachment),
Text(note.pinned ? 'Unpin' : 'Pin'),
],
),
),
PopupMenuItem<String>(
value: 'addAttachment',
child: Row(
children: <Widget>[
Icon(
MdiIcons.filePlus,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
for (String attachment in note.attachments)
PopupMenuItem<String>(
value: 'removeAttachment.$attachment',
child: Row(
children: <Widget>[
Icon(
MdiIcons.paperclip,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Flexible(
child: Text(attachment),
),
],
),
Text('Add Attachment'),
],
),
),
for (String tag in note.tags)
),
PopupMenuItem<String>(
value: 'removeTag.$tag',
value: 'addAttachment',
child: Row(
children: <Widget>[
Icon(
MdiIcons.tag,
MdiIcons.filePlus,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text(tag),
Text('Add Attachment'),
],
),
),
PopupMenuItem<String>(
value: 'addTag',
child: Row(
children: <Widget>[
Icon(
MdiIcons.tagPlus,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
for (String tag in note.tags)
PopupMenuItem<String>(
value: 'removeTag.$tag',
child: Row(
children: <Widget>[
Icon(
MdiIcons.tag,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text(tag),
],
),
Text('Add Tag'),
],
),
PopupMenuItem<String>(
value: 'addTag',
child: Row(
children: <Widget>[
Icon(
MdiIcons.tagPlus,
color: Theme.of(context).colorScheme.onSurface,
),
SizedBox(
width: 8,
),
Text('Add Tag'),
],
),
),
),
],
];
},
)
],
),
Expand Down
43 changes: 35 additions & 8 deletions lib/page/note_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:package_info/package_info.dart';
import 'package:preferences/preferences.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:quick_actions/quick_actions.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
// import 'package:receive_sharing_intent/receive_sharing_intent.dart';

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

// StreamSubscription _intentDataStreamSubscription;
StreamSubscription _intentDataStreamSubscription;

@override
void initState() {
Expand Down Expand Up @@ -62,20 +63,20 @@ class _NoteListPageState extends State<NoteListPage> {
icon: 'ic_shortcut_add'),
]);

/* // For sharing or opening urls/text coming from outside the app while the app is in the memory
// For sharing or opening urls/text coming from outside the app while the app is in the memory
_intentDataStreamSubscription =
ReceiveSharingIntent.getTextStream().listen((String value) {
print('SHARED $value');
handleSharedText(value);
ReceiveSharingIntent.reset();
}, onError: (err) {
print("getLinkStream error: $err");
});

// For sharing or opening urls/text coming from outside the app while the app is closed
ReceiveSharingIntent.getInitialText().then((String value) {
print('SHARED $value');
handleSharedText(value);
ReceiveSharingIntent.reset();
}); */
});
}
});

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

@override
void dispose() {
// _intentDataStreamSubscription.cancel();
_intentDataStreamSubscription.cancel();
super.dispose();
}

handleSharedText(String value) {
if (value == null) return;

showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Received text'),
content:
Scrollbar(child: SingleChildScrollView(child: Text(value))),
actions: [
FlatButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Cancel')),
// FlatButton(onPressed: () {}, child: Text('Append to note')),
FlatButton(
onPressed: () {
Navigator.of(context).pop();
createNewNote(value);
},
child: Text('Create new note')),
],
));
}

Future<bool> _onWillPop() async {
if (_selectedNotes.isNotEmpty) {
setState(() {
Expand Down Expand Up @@ -953,7 +980,7 @@ class _NoteListPageState extends State<NoteListPage> {
);
}

Future<void> createNewNote() async {
Future<void> createNewNote([String content = '']) async {
Note newNote = Note();
int i = 1;
while (true) {
Expand Down Expand Up @@ -986,7 +1013,7 @@ class _NoteListPageState extends State<NoteListPage> {

_filterAndSortNotes();

await PersistentStore.saveNote(newNote, '# ${newNote.title}\n\n');
await PersistentStore.saveNote(newNote, '# ${newNote.title}\n\n$content');

await Navigator.of(context).push(MaterialPageRoute(
builder: (context) => EditPage(
Expand Down
8 changes: 8 additions & 0 deletions lib/page/preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ pre {
max-width: 100%;
overflow-x: scroll;
}
blockquote{
padding: 0em 0em 0em .6em;
margin-left: .1em;
border-left: 0.3em solid ${theme.brightness == Brightness.light ? 'lightgrey' : 'grey'};
}
</style>
</head>
<body>
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
receive_sharing_intent:
dependency: "direct main"
description:
name: receive_sharing_intent
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
rich_code_editor:
dependency: "direct main"
description:
Expand Down
Loading

0 comments on commit 34175f4

Please sign in to comment.