Commit df9fcbcb authored by Jay Naik's avatar Jay Naik

removed debug corner badge from the app, added an invisible divider between...

removed debug corner badge from the app, added an invisible divider between title and content of the staggered view tile in the staggered view for better look. increased title font size in the note edit page(in notePage.dart)
parent df5f7f65
import 'dart:convert';
import 'package:flutter/material.dart';
import '../Views/StaggeredTiles.dart';
class Note {
int id;
......
......@@ -11,7 +11,7 @@ class NotesDBHandler {
final databaseName = "notes.db";
final tableName = "notes";
//TODO: develop a function to build the create query from this column:properties dictionary.
final fieldMap = {
"id": "INTEGER PRIMARY KEY AUTOINCREMENT",
"title": "BLOB",
......@@ -72,7 +72,7 @@ class NotesDBHandler {
// " )"
// build the create query dynamically using the column:field dictionary.
String _buildCreateQuery() {
String query = "CREATE TABLE IF NOT EXISTS ";
query += tableName;
......@@ -107,7 +107,7 @@ class NotesDBHandler {
);
if (isNew) {
// get latest note which isn't archived limit by 1
// get latest note which isn't archived, limit by 1
var one = await db.query("notes", orderBy: "date_last_edited desc",
where: "is_archived = ?",
whereArgs: [0],
......@@ -119,36 +119,47 @@ class NotesDBHandler {
}
Future<List<Note>> selectAllNotes() async {
// acquire database connection instance
// Future<List<Note>> selectAllNotes() async {
// // acquire database connection instance
// final Database db = await database;
// // query all the notes sorted by last edited
// var data = await db.query("notes", orderBy: "date_last_edited desc",
// where: "is_archived = ?",
// whereArgs: [0]);
//
// List<Note> notes = [];
//
//// List<Map<String,dynamic>>
// // create
// data.forEach((row) {
// String title = row["title"] == null ? "" : utf8.decode(row["title"]);
// String content = row["content"] == null ? "" : utf8.decode(
// row["content"]);
//
// var tempNote = Note(
// row["id"],
// title,
// content,
// DateTime.fromMillisecondsSinceEpoch(row["date_created"] * 1000),
// DateTime.fromMillisecondsSinceEpoch(row["date_last_edited"] * 1000),
// Color(row["note_color"])
// );
// print("tempNote $tempNote");
// notes.add(tempNote);
// });
//
// return notes;
// }
Future<bool> copyNote(Note note) async {
final Database db = await database;
// query all the notes sorted by last edited
var data = await db.query("notes", orderBy: "date_last_edited desc",
where: "is_archived = ?",
whereArgs: [0]);
List<Note> notes = [];
// List<Map<String,dynamic>>
// create
data.forEach((row) {
String title = row["title"] == null ? "" : utf8.decode(row["title"]);
String content = row["content"] == null ? "" : utf8.decode(
row["content"]);
var tempNote = Note(
row["id"],
title,
content,
DateTime.fromMillisecondsSinceEpoch(row["date_created"] * 1000),
DateTime.fromMillisecondsSinceEpoch(row["date_last_edited"] * 1000),
Color(row["note_color"])
);
print("tempNote $tempNote");
notes.add(tempNote);
});
return notes;
try {
await db.insert("notes",note.toMap(), conflictAlgorithm: ConflictAlgorithm.replace);
} catch(Error) {
print(Error);
return false;
}
return true;
}
......
......@@ -88,7 +88,7 @@ class _NotePageState extends State<NotePage> {
Container(
color: note_color,
padding: EdgeInsets.only(left: 16, right: 16, top: 10),
padding: EdgeInsets.only(left: 16, right: 16, top: 12),
child:
SafeArea(child:
......@@ -96,6 +96,9 @@ class _NotePageState extends State<NotePage> {
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Flexible(
child: Container(
padding: EdgeInsets.all(5),
// decoration: BoxDecoration(border: Border.all(color: CentralStation.borderColor,width: 1 ),borderRadius: BorderRadius.all(Radius.circular(10)) ),
child: EditableText(
onChanged: (str) => {updateNoteObject()},
maxLines: null,
......@@ -103,15 +106,18 @@ class _NotePageState extends State<NotePage> {
focusNode: _titleFocus,
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontSize: 22,
fontWeight: FontWeight.bold),
cursorColor: Colors.blue,
backgroundCursorColor: Colors.blue),
),
),
Divider(color: CentralStation.borderColor,),
Flexible(
Flexible( child: Container(
padding: EdgeInsets.all(5),
// decoration: BoxDecoration(border: Border.all(color: CentralStation.borderColor,width: 1),borderRadius: BorderRadius.all(Radius.circular(10)) ),
child: EditableText(
onChanged: (str) => {updateNoteObject()},
maxLines: 300, // line limit extendable later
......@@ -120,7 +126,10 @@ class _NotePageState extends State<NotePage> {
style: TextStyle(color: Colors.black, fontSize: 20),
backgroundCursorColor: Colors.red,
cursorColor: Colors.blue,
))
)
)
)
],
),
left: true,right: true,top: false,bottom: false,
......@@ -275,7 +284,8 @@ class _NotePageState extends State<NotePage> {
break;
}
case moreOptions.copy : {
// send note to copy query and
// TODO: call query -> set needs update flag true -> pop
_copy();
break;
}
}
......@@ -389,6 +399,29 @@ class _NotePageState extends State<NotePage> {
Scaffold.of(context).showSnackBar(new SnackBar(content: Text("deleted")));
}
void _copy(){
var noteDB = NotesDBHandler();
Note copy = Note(-1,
_editableNote.title,
_editableNote.content,
DateTime.now(),
DateTime.now(),
_editableNote.note_color) ;
// copy.date_created = DateTime.now();
// copy.date_last_edited = DateTime.now();
var status = noteDB.copyNote(copy);
status.then((query_success){
if (query_success){
CentralStation.updateNeeded = true;
Navigator.of(_globalKey.currentContext).pop();
}
});
}
void _undo() {
_titleController.text = widget.noteInEditing.title;
_contentController.text = widget.noteInEditing.content;
......
......@@ -8,10 +8,7 @@ import 'dart:convert';
import '../Models/Utility.dart';
import 'HomePage.dart';
//enum viewType {
// List,
// Staggered
//}
class StaggeredGridPage extends StatefulWidget {
......@@ -34,7 +31,7 @@ class _StaggeredGridPageState extends State<StaggeredGridPage> {
var noteDB = NotesDBHandler();
var _allNotesInDict = [];
// var _allNotesInDict = [];
List<Map<String, dynamic>> _allNotesInQueryResult = [];
viewType notesViewType ;
......@@ -56,8 +53,7 @@ class _StaggeredGridPageState extends State<StaggeredGridPage> {
@override
Widget build(BuildContext context) {
var shortestSide = MediaQuery.of(context).size.shortestSide;
final bool useMobileLayout = shortestSide < 600 ;
GlobalKey _stagKey = GlobalKey();
print("update needed?: ${CentralStation.updateNeeded}");
......@@ -66,14 +62,13 @@ GlobalKey _stagKey = GlobalKey();
}
return OrientationBuilder(
builder: (context, orientation) {
return Container(child: Padding(padding: _paddingForView(context)/*EdgeInsets.all(8.0)*/ , child:
return Container(child: Padding(padding: _paddingForView(context) , child:
new StaggeredGridView.count(key: _stagKey,
crossAxisSpacing: 6,
mainAxisSpacing: 6,
crossAxisCount: _colForStaggeredView(context,orientation),
children: List.generate(_allNotesInQueryResult.length/*_allNotesInDict.length*/, (i){ return _tileGenerator(i) ; }),//_tilesFromAllData(),
// staggeredTiles: List.generate(_allNotesInDict.length, (i){ return StaggeredTile.fit(widget.notesViewType == viewType.List ? 1 : 2); }) /*_tilesSize*/,)
children: List.generate(_allNotesInQueryResult.length, (i){ return _tileGenerator(i) ; }),//_tilesFromAllData(),
staggeredTiles: _tilesForView() ,
),
) );
......@@ -95,7 +90,7 @@ GlobalKey _stagKey = GlobalKey();
}
List<StaggeredTile> _tilesForView() {
return List.generate(_allNotesInQueryResult.length/*_allNotesInDict.length*/,(index){ return StaggeredTile.fit( widget.notesViewType == viewType.List ? 1 : 2 ); }
return List.generate(_allNotesInQueryResult.length,(index){ return StaggeredTile.fit( widget.notesViewType == viewType.List ? 1 : 2 ); }
) ;
}
......@@ -132,15 +127,6 @@ EdgeInsets _paddingForView(BuildContext context){
Color(_allNotesInQueryResult[i]["note_color"] ))
);
// return MyStaggeredTile( Note(_allNotesInDict[i].id, // later when selestAll will be returning "List<Map<String,dynamic>>" use ["id"] instead of .id
// _allNotesInDict[i].title,
// _allNotesInDict[i].content,
// _allNotesInDict[i].date_created,
// _allNotesInDict[i].date_last_edited,
// _allNotesInDict[i].note_color,
// ) ) ;
}
......
import 'package:flutter/material.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'dart:math';
import '../ViewControllers/NotePage.dart';
import '../Models/Note.dart';
import '../Models/Utility.dart';
......@@ -39,7 +38,7 @@ class _MyStaggeredTileState extends State<MyStaggeredTile> {
border: tileColor == Colors.white ? Border.all(color: CentralStation.borderColor) : null,
color: tileColor,
borderRadius: BorderRadius.all(Radius.circular(8))),
padding: EdgeInsets.all(7),
padding: EdgeInsets.all(8),
child: constructChild(),) ,
)
;
......@@ -65,7 +64,7 @@ class _MyStaggeredTileState extends State<MyStaggeredTile> {
textScaleFactor: 1.5,
),
Divider(color: Colors.transparent,height: 6,),
AutoSizeText(
_content,
......@@ -81,7 +80,6 @@ class _MyStaggeredTileState extends State<MyStaggeredTile> {
double _determineFontSizeForContent() {
// print(widget.note.title);
int charCount = _content.length + widget.note.title.length ;
double fontSize = 20 ;
if (charCount > 110 ) { fontSize = 12; }
......
......@@ -11,6 +11,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
fontFamily: "Roboto",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment