Skip to content

Commit

Permalink
Merge pull request #7 from Wrth1/customize-text
Browse files Browse the repository at this point in the history
Major Update: Customize text format
  • Loading branch information
Wrth1 authored Apr 7, 2024
2 parents 930e5ac + 1260f5e commit 6642ae1
Show file tree
Hide file tree
Showing 14 changed files with 531 additions and 329 deletions.
2 changes: 2 additions & 0 deletions .idx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

gc/
46 changes: 46 additions & 0 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{pkgs}: {
channel = "stable-23.11";
packages = [
pkgs.flutter
pkgs.jdk17
];
idx.extensions = [

];
idx.previews = {
previews = [
{
command = [
"flutter"
"run"
"--machine"
"-d"
"web-server"
"--web-hostname"
"0.0.0.0"
"--web-port"
"$PORT"
];
id = "web";
manager = "flutter";
}
{
command = [
"flutter"
"run"
"--machine"
"-d"
"android"
"-d"
"emulator-5554"
];
id = "android";
manager = "flutter";
}
{
id = "ios";
manager = "ios";
}
];
};
}
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ android {
applicationId "com.wrth.notease"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
minSdkVersion 23
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
172 changes: 59 additions & 113 deletions lib/home.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'dart:convert';
import 'dart:math';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_quill/flutter_quill.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:testnote/list.dart';
Expand All @@ -20,7 +22,10 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
Map<int, String> notes = {};
int editingIndex = -1;
final FirebaseAuth _auth = FirebaseAuth.instance;
final TextEditingController _noteController = TextEditingController();
final _noteController = QuillController(
keepStyleOnNewLine: false,
document: Document(),
selection: const TextSelection.collapsed(offset: 0));
final FirebaseFirestore db = FirebaseFirestore.instance;
dynamic userData;
dynamic notesDocRef;
Expand Down Expand Up @@ -65,6 +70,31 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
),
),
),
title: GestureDetector(
onTap: () {
// Open the link when the title is clicked
launchUrl(Uri(
scheme: 'https',
host: 'binusianorg-my.sharepoint.com',
path:
'/personal/bill_elim_binus_ac_id/_layouts/15/guestaccess.aspx',
queryParameters: {
'share': 'EkEQg25whCZKtZOdahpRq5kBQybA6nFJ-an02U60GhuOdg',
'e': 'pW9qBv',
},
));
},
child: const MouseRegion(
cursor: SystemMouseCursors.click,
child: Text(
"Notease - v0.5.0 | 4 April 2024",
style: TextStyle(
color: Color.fromARGB(255, 30, 29, 29),
fontWeight: FontWeight.bold,
),
),
),
),
actions: [
// IconButton(
// icon: const Icon(
Expand Down Expand Up @@ -112,124 +142,40 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
),
),
],
title: GestureDetector(
onTap: () {
// Open the link when the title is clicked
launchUrl(Uri(
scheme: 'https',
host: 'binusianorg-my.sharepoint.com',
path:
'/personal/bill_elim_binus_ac_id/_layouts/15/guestaccess.aspx',
queryParameters: {
'share': 'EkEQg25whCZKtZOdahpRq5kBQybA6nFJ-an02U60GhuOdg',
'e': 'pW9qBv',
},
));
},
child: const MouseRegion(
cursor: SystemMouseCursors.click,
child: Text(
"Notease - v0.4.1 | 26 Maret 2024",
style: TextStyle(
color: Color.fromARGB(255, 30, 29, 29),
fontWeight: FontWeight.bold,
),
),
),
),
backgroundColor: const Color.fromARGB(255, 255, 255, 255),
),
body: Column(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 25.0), // Menambahkan padding horizontal
child: TextField(
key: const Key('note_text_field'),
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: QuillEditor.basic(
configurations: QuillEditorConfigurations(
controller: _noteController,
readOnly: false,
sharedConfigurations: const QuillSharedConfigurations(
locale: Locale('en'),
),
),
),
),
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: QuillToolbar.simple(
configurations: QuillSimpleToolbarConfigurations(
controller: _noteController,
maxLines: null,
expands: true,
textAlignVertical:
TextAlignVertical.top, // Mengatur teks ke atas
textAlign: TextAlign.start, // Mengatur teks ke kiri
decoration: const InputDecoration(
hintText: 'Enter your note',
contentPadding: EdgeInsets.symmetric(
vertical: 30.0), // Menambahkan padding vertikal
sharedConfigurations: const QuillSharedConfigurations(
locale: Locale('en'),
),
onSubmitted: (note) {
_addNote();
},
showSubscript: false,
showSuperscript: false,
showFontFamily: false,
),
),
),
],
),
// bottomNavigationBar: BottomAppBar(
// elevation: 0, // Menghapus efek bayangan
// shape: const CircularNotchedRectangle(),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: [
// IconButton(
// icon: const Icon(Icons.highlight, size: 30, color: Colors.black),
// onPressed: () {
// // Handle highlight text button press
// },
// tooltip: "Highlight",
// ),
// IconButton(
// icon: const Icon(Icons.format_italic_rounded,
// size: 30, color: Colors.black),
// onPressed: () {
// // Handle highlight text button press
// },
// tooltip: "Highlight",
// ),
// IconButton(
// icon: const Icon(Icons.format_bold_rounded,
// size: 30, color: Colors.black),
// onPressed: () {
// // Handle highlight text button press
// },
// tooltip: "Highlight",
// ),
// IconButton(
// icon: const Icon(Icons.format_underline_rounded,
// size: 30, color: Colors.black),
// onPressed: () {
// // Handle highlight text button press
// },
// tooltip: "Highlight",
// ),
// IconButton(
// icon:
// const Icon(Icons.undo_rounded, size: 30, color: Colors.black),
// onPressed: () {
// // Handle undo button press
// },
// tooltip: "Undo",
// ),
// IconButton(
// icon:
// const Icon(Icons.redo_rounded, size: 30, color: Colors.black),
// onPressed: () {
// // Handle redo button press
// },
// tooltip: "Redo",
// ),
// IconButton(
// icon: const Icon(Icons.attach_file_rounded,
// size: 30, color: Colors.black),
// onPressed: () {
// // Handle add attachment button press
// },
// tooltip: "Attach-file",
// ),
// ],
// ),
// ),
);
}

Expand All @@ -244,7 +190,8 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
) ??
oldEditingIndex;
if (editingIndex != -1) {
_noteController.text = notes[editingIndex]!;
_noteController.document =
Document.fromJson(jsonDecode(notes[editingIndex]!));
} else if (oldEditingIndex != editingIndex) {
_noteController.clear();
}
Expand Down Expand Up @@ -272,10 +219,7 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
'username': currentUser.email,
});
notesDocRef.set({
'notes': {
'0':
'Omg Bill ganteng banget dan tidak narsis (test note pertama jangan lupa dihapus pas production)'
},
'notes': {'0': r'[{"insert":"Hello, World!\n"}]'},
});
userData = {
'username': currentUser.email,
Expand All @@ -302,7 +246,8 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
if (editingIndex == -1) {
editingIndex = notes.isEmpty ? 0 : notes.keys.reduce(max) + 1;
}
notes[editingIndex] = _noteController.text;
notes[editingIndex] =
jsonEncode(_noteController.document.toDelta().toJson());

if (_auth.currentUser == null) {
final prefs = await SharedPreferences.getInstance();
Expand All @@ -311,7 +256,8 @@ class _NotepadHomePageState extends State<NotepadHomePage> {
await prefs.setStringList('notes', notes.values.toList());
} else {
notesDocRef.update({
'notes.$editingIndex': _noteController.text,
'notes.$editingIndex':
jsonEncode(_noteController.document.toDelta().toJson()),
}).then(
(value) {},
onError: (e) => print("Error saving note: $e"),
Expand Down
Loading

0 comments on commit 6642ae1

Please sign in to comment.