Skip to content

Commit

Permalink
IMPROVED: Database loading and icon themes
Browse files Browse the repository at this point in the history
  • Loading branch information
ihni7 committed Sep 6, 2020
1 parent e7f7b97 commit 2deb4d3
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 106 deletions.
157 changes: 78 additions & 79 deletions lib/screens/add_note.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:note_app/data/note_database.dart';
import 'package:note_app/widgets/widgets.dart';
Expand All @@ -20,7 +21,6 @@ class _AddNoteState extends State<AddNote> {

@override
Widget build(BuildContext context) {

final colorList = [
Color(0xFF82DEE9),
Color(0xFFFEAA93),
Expand Down Expand Up @@ -60,85 +60,87 @@ class _AddNoteState extends State<AddNote> {
}

return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomAppbar(
onTap: () {
widget.note == null ? createNote() : updateNote();
Navigator.pop(context);
},
),
SizedBox(height: 25),
LimitedBox(
maxHeight: 50,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: colorList.length,
itemBuilder: (context, index) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () {
color = colorList[index];
},
child: Container(
height: 45,
width: 45,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: colorList[index],
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomAppbar(
onTap: () {
widget.note == null ? createNote() : updateNote();
Navigator.pop(context);
},
),
SizedBox(height: 25),
LimitedBox(
maxHeight: 50,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: colorList.length,
itemBuilder: (context, index) {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
InkWell(
onTap: () {
color = colorList[index];
},
child: Container(
height: 45,
width: 45,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: colorList[index],
),
//child: colorList[index] == color
// ? Icon(Icons.done)
// : Container(),
),
//child: colorList[index] == color
// ? Icon(Icons.done)
// : Container(),
),
),
SizedBox(width: 10),
],
);
},
SizedBox(width: 10),
],
);
},
),
),
),
TextField(
controller: _titleController,
keyboardType: TextInputType.multiline,
maxLines: null,
style: TextStyle(fontSize: 35),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Title',
hintStyle: TextStyle(fontSize: 35),
TextField(
controller: _titleController,
keyboardType: TextInputType.multiline,
maxLines: null,
style: TextStyle(fontSize: 35),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Title',
hintStyle: TextStyle(fontSize: 35),
),
),
),
SizedBox(height: 20),
widget.note != null
? Text(
DateFormat.yMMMMd('en_US').format(widget.note.createdAt),
style: TextStyle(
fontSize: 16,
color: Colors.grey[700],
),
)
: Container(),
widget.note != null ? SizedBox(height: 20) : Container(),
TextField(
controller: _descriptionController,
keyboardType: TextInputType.multiline,
maxLines: null,
style: TextStyle(fontSize: 22),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Type Something...',
hintStyle: TextStyle(fontSize: 22),
SizedBox(height: 20),
widget.note != null
? Text(
DateFormat.yMMMMd('en_US').format(widget.note.createdAt),
style: TextStyle(
fontSize: 16,
color: Colors.grey[700],
),
)
: Container(),
widget.note != null ? SizedBox(height: 20) : Container(),
TextField(
controller: _descriptionController,
keyboardType: TextInputType.multiline,
maxLines: null,
style: TextStyle(fontSize: 22),
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Type Something...',
hintStyle: TextStyle(fontSize: 22),
),
),
),
],
],
),
),
),
floatingActionButton: widget.note != null
Expand All @@ -148,10 +150,7 @@ class _AddNoteState extends State<AddNote> {
Navigator.pop(context);
},
backgroundColor: Colors.red[400],
child: Icon(
Icons.delete,
color: Colors.white,
),
child: FaIcon(FontAwesomeIcons.trashAlt),
)
: Container(),
);
Expand Down
20 changes: 15 additions & 5 deletions lib/screens/note_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flushbar/flushbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:note_app/data/note_database.dart';
import 'package:note_app/screens/add_note.dart';
import 'package:note_app/widgets/note_card.dart';
Expand All @@ -23,7 +25,7 @@ class NoteScreen extends StatelessWidget {
children: [
Text(
'Notes',
style: TextStyle(fontSize: 35),
style: TextStyle(fontSize: 35, fontWeight: FontWeight.w600),
),
InkWell(
onTap: () {
Expand Down Expand Up @@ -85,7 +87,8 @@ class NoteScreen extends StatelessWidget {
borderRadius: BorderRadius.circular(10),
),
child: Center(
child: Icon(Icons.search),
child: Center(
child: FaIcon(FontAwesomeIcons.search)),
),
),
),
Expand All @@ -101,7 +104,7 @@ class NoteScreen extends StatelessWidget {
color: Colors.grey[800],
borderRadius: BorderRadius.circular(10),
),
child: Icon(Icons.search),
child: Center(child: FaIcon(FontAwesomeIcons.search)),
),
),
],
Expand All @@ -112,6 +115,13 @@ class NoteScreen extends StatelessWidget {
stream: database.watchAllNotes(),
builder: (context, snapshot) {
final notes = snapshot.data ?? List();
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: SpinKitCircle(
color: Colors.white,
size: 50,
));
}
return snapshot.data.length > 0
? GridView.count(
physics: BouncingScrollPhysics(),
Expand Down Expand Up @@ -164,8 +174,8 @@ class NoteScreen extends StatelessWidget {
Navigator.push(context, MaterialPageRoute(builder: (_) => AddNote()));
},
backgroundColor: Colors.grey[800],
child: Icon(
Icons.add,
child: FaIcon(
FontAwesomeIcons.plus,
color: Colors.white,
),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/search_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:note_app/data/note_database.dart';
import 'package:note_app/screens/add_note.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -45,7 +46,7 @@ class _SearchScreenState extends State<SearchScreen> {
});
});
},
child: Icon(Icons.search),
child: FaIcon(FontAwesomeIcons.search),
),
],
),
Expand Down
5 changes: 3 additions & 2 deletions lib/widgets/custom_appbar.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class CustomAppbar extends StatelessWidget {
final Function onTap;
Expand Down Expand Up @@ -26,7 +27,7 @@ class CustomAppbar extends StatelessWidget {
color: Colors.grey[800],
borderRadius: BorderRadius.circular(10),
),
child: Icon(Icons.arrow_back_ios),
child: Center(child: FaIcon(FontAwesomeIcons.search)),
),
),
GestureDetector(
Expand All @@ -41,7 +42,7 @@ class CustomAppbar extends StatelessWidget {
child: Center(
child: Text(
'Save',
style: TextStyle(fontWeight: FontWeight.bold),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
),
),
),
Expand Down
Loading

0 comments on commit 2deb4d3

Please sign in to comment.