diff --git a/Tajawal/OFL.txt b/Tajawal/OFL.txt
new file mode 100644
index 0000000..8cdc822
--- /dev/null
+++ b/Tajawal/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2018 Boutros International. (http://www.boutrosfonts.com)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/Tajawal/Tajawal-Black.ttf b/Tajawal/Tajawal-Black.ttf
new file mode 100644
index 0000000..f9a40b5
Binary files /dev/null and b/Tajawal/Tajawal-Black.ttf differ
diff --git a/Tajawal/Tajawal-Bold.ttf b/Tajawal/Tajawal-Bold.ttf
new file mode 100644
index 0000000..081ac58
Binary files /dev/null and b/Tajawal/Tajawal-Bold.ttf differ
diff --git a/Tajawal/Tajawal-ExtraBold.ttf b/Tajawal/Tajawal-ExtraBold.ttf
new file mode 100644
index 0000000..2904c3c
Binary files /dev/null and b/Tajawal/Tajawal-ExtraBold.ttf differ
diff --git a/Tajawal/Tajawal-ExtraLight.ttf b/Tajawal/Tajawal-ExtraLight.ttf
new file mode 100644
index 0000000..a3e2686
Binary files /dev/null and b/Tajawal/Tajawal-ExtraLight.ttf differ
diff --git a/Tajawal/Tajawal-Light.ttf b/Tajawal/Tajawal-Light.ttf
new file mode 100644
index 0000000..dfc9d93
Binary files /dev/null and b/Tajawal/Tajawal-Light.ttf differ
diff --git a/Tajawal/Tajawal-Medium.ttf b/Tajawal/Tajawal-Medium.ttf
new file mode 100644
index 0000000..4176ac1
Binary files /dev/null and b/Tajawal/Tajawal-Medium.ttf differ
diff --git a/Tajawal/Tajawal-Regular.ttf b/Tajawal/Tajawal-Regular.ttf
new file mode 100644
index 0000000..747f56c
Binary files /dev/null and b/Tajawal/Tajawal-Regular.ttf differ
diff --git a/fonts/Tajawal/OFL.txt b/fonts/Tajawal/OFL.txt
new file mode 100644
index 0000000..8cdc822
--- /dev/null
+++ b/fonts/Tajawal/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2018 Boutros International. (http://www.boutrosfonts.com)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/fonts/Tajawal/Tajawal-Black.ttf b/fonts/Tajawal/Tajawal-Black.ttf
new file mode 100644
index 0000000..f9a40b5
Binary files /dev/null and b/fonts/Tajawal/Tajawal-Black.ttf differ
diff --git a/fonts/Tajawal/Tajawal-Bold.ttf b/fonts/Tajawal/Tajawal-Bold.ttf
new file mode 100644
index 0000000..081ac58
Binary files /dev/null and b/fonts/Tajawal/Tajawal-Bold.ttf differ
diff --git a/fonts/Tajawal/Tajawal-ExtraBold.ttf b/fonts/Tajawal/Tajawal-ExtraBold.ttf
new file mode 100644
index 0000000..2904c3c
Binary files /dev/null and b/fonts/Tajawal/Tajawal-ExtraBold.ttf differ
diff --git a/fonts/Tajawal/Tajawal-ExtraLight.ttf b/fonts/Tajawal/Tajawal-ExtraLight.ttf
new file mode 100644
index 0000000..a3e2686
Binary files /dev/null and b/fonts/Tajawal/Tajawal-ExtraLight.ttf differ
diff --git a/fonts/Tajawal/Tajawal-Light.ttf b/fonts/Tajawal/Tajawal-Light.ttf
new file mode 100644
index 0000000..dfc9d93
Binary files /dev/null and b/fonts/Tajawal/Tajawal-Light.ttf differ
diff --git a/fonts/Tajawal/Tajawal-Medium.ttf b/fonts/Tajawal/Tajawal-Medium.ttf
new file mode 100644
index 0000000..4176ac1
Binary files /dev/null and b/fonts/Tajawal/Tajawal-Medium.ttf differ
diff --git a/fonts/Tajawal/Tajawal-Regular.ttf b/fonts/Tajawal/Tajawal-Regular.ttf
new file mode 100644
index 0000000..747f56c
Binary files /dev/null and b/fonts/Tajawal/Tajawal-Regular.ttf differ
diff --git a/images/pexels-photo-9519451-2.jpg b/images/pexels-photo-9519451-2.jpg
new file mode 100644
index 0000000..41f833b
Binary files /dev/null and b/images/pexels-photo-9519451-2.jpg differ
diff --git a/images/undraw_Login_re_4vu2.png b/images/undraw_Login_re_4vu2.png
new file mode 100644
index 0000000..dc8ca92
Binary files /dev/null and b/images/undraw_Login_re_4vu2.png differ
diff --git a/images/undraw_Login_re_4vu2.svg b/images/undraw_Login_re_4vu2.svg
new file mode 100644
index 0000000..7a10186
--- /dev/null
+++ b/images/undraw_Login_re_4vu2.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/lib/data.dart b/lib/data.dart
new file mode 100644
index 0000000..9f78946
--- /dev/null
+++ b/lib/data.dart
@@ -0,0 +1,77 @@
+
+import 'models/contact.dart';
+
+var contacts = [
+ Contact(
+ 'https://i.pravatar.cc/300',
+ 'Ahmed',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(seconds: 3),
+ ),
+ true,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/301',
+ 'Ali',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 1),
+ ),
+ false,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/302',
+ 'Kamal',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 3),
+ ),
+ true,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/303',
+ 'Mohammad',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 5),
+ ),
+ true,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/304',
+ 'Mohammad',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 5),
+ ),
+ false,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/305',
+ 'Hussein',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 6),
+ ),
+ false,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/306',
+ 'Aboud',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 7),
+ ),
+ false,
+ ),
+ Contact(
+ 'https://i.pravatar.cc/307',
+ 'Osama',
+ '71766137347',
+ DateTime.now().add(
+ const Duration(days: 6),
+ ),
+ false,
+ ),
+];
\ No newline at end of file
diff --git a/lib/login_page.dart b/lib/login_page.dart
new file mode 100644
index 0000000..192556d
--- /dev/null
+++ b/lib/login_page.dart
@@ -0,0 +1,77 @@
+import 'package:flutter/cupertino.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_svg/svg.dart';
+
+class LoginPage extends StatefulWidget {
+ @override
+ State createState() => _LoginPageState();
+}
+
+class _LoginPageState extends State {
+ var emailTextController = TextEditingController();
+ var passwordTextController = TextEditingController();
+
+ @override
+ Widget build(BuildContext context) {
+
+ var headerImage = SvgPicture.asset(
+ 'images/undraw_Login_re_4vu2.svg',
+ height: 200,
+ semanticsLabel: 'Acme Logo'
+ );
+
+ return ListView(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 30),
+ child: headerImage,
+ ),
+ Container(height: 30,),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Card(
+ shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ) ,
+ elevation: 0,
+ child: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: TextField(
+ textAlign: TextAlign.center,
+ controller: emailTextController,
+ decoration: InputDecoration(
+ hintText: 'Email'
+ ),
+ ),
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Card(
+ elevation: 0,
+ shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ) ,
+ child: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: TextField(
+ textAlign: TextAlign.center,
+ controller: passwordTextController,
+ decoration: InputDecoration(
+ hintText: 'Password'
+ ),
+ ),
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: ElevatedButton(onPressed: () {
+ if (emailTextController.text.isEmpty) {
+ debugPrint('emailTextController.text is empty...');
+ }
+ debugPrint('emailTextController.text: ${emailTextController.text}');
+ debugPrint('passwordTextController.text: ${passwordTextController.text}');
+ }, child: Text('Login')),
+ )
+ ],
+ );
+ }
+}
diff --git a/lib/main.dart b/lib/main.dart
index 6945de6..7dd3868 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,31 +1,26 @@
+// ignore_for_file: must_call_super
+
+import 'package:contacts_01/ui/new_note_page.dart';
import 'package:flutter/material.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+import 'models/note.dart';
void main() {
runApp(const MyApp());
}
-class Contact {
- String image;
- String name;
- String mobileNumber;
- DateTime date;
- bool isIncoming;
-
- Contact(this.image, this.name, this.mobileNumber, this.date, this.isIncoming);
-}
-
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
- title: 'Flutter Demo 2',
+ title: 'Notes App',
theme: ThemeData(
- primarySwatch: Colors.blue,
+ primarySwatch: Colors.amber,
),
debugShowCheckedModeBanner: false,
- home: const MyHomePage(title: 'Contacts App'),
+ home: const MyHomePage(title: 'notes app'),
);
}
}
@@ -40,197 +35,103 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State {
- Widget buildContactItem(Contact _contact) {
- return Card(
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Row(
- children: [
- CircleAvatar(
- backgroundImage: NetworkImage(_contact.image),
- ),
- Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- _contact.name,
- style: const TextStyle(fontWeight: FontWeight.bold),
- ),
- Text(_contact.mobileNumber),
- ],
- ),
- ),
- Text(_contact.date.toIso8601String().split('T').first),
- Expanded(
- child: Container(),
- ),
- if (_contact.isIncoming)
- Icon(
- Icons.arrow_downward,
- color: Colors.red,
- )
- else
- Icon(
- Icons.arrow_upward,
- color: Colors.green,
- )
- ],
- ),
- ),
- );
- }
+ var notes = [];
+ List notestobesaved = [];
- Widget buildIGCard() {
- var imageUrl = 'https://images.pexels.com/photos/1544947/pexels-photo-1544947.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500';
+ void removeNote(NoteModel note, int index) {
+ notes.remove(note);
+ notestobesaved.removeAt(index);
+ setState(() {});
+ }
- return Container(
- // color: Color(0xff162f5a),
- decoration: BoxDecoration(
- border: Border.all(color: Colors.white, width: 6),
- color: Color(0xff162f5a)
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
- children: [
- Image.network(
- imageUrl,
- height: 300,
- width: double.maxFinite,
- fit: BoxFit.cover,
- ),
- Row(
+ Widget noteItemView(NoteModel note, index) {
+ return Card(
+ child: InkWell(
+ onTap: () {
+ openNewNote(noteModel: note);
+ },
+ child: Padding(
+ padding: const EdgeInsets.all(20),
+ child: Row(
children: [
- Padding(
- padding: const EdgeInsets.all(16),
- child: Icon(
- Icons.favorite_outline,
- color: Colors.white,
- size: 45,
- ),
- ),
- Padding(
- padding: const EdgeInsets.all(16),
- child: Icon(
- Icons.location_on_outlined,
- color: Colors.white,
- size: 45,
+ Expanded(
+ child: Text(
+ note.content,
+ maxLines: 1,
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyle(fontSize: 20),
),
),
Expanded(
child: Container(),
),
- Padding(
- padding: const EdgeInsets.all(16),
- child: Icon(
- Icons.more_vert,
- color: Colors.white,
- size: 45,
- ),
+ IconButton(
+ icon: Icon(Icons.remove_circle_outline),
+ onPressed: () => removeNote(note, index),
),
],
),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: Text('25 Likes', style: TextStyle(
- color: Colors.white, fontSize: 30,
- fontWeight: FontWeight.w800
- ),),
- ),
- ],
+ ),
),
);
}
+ Widget buildNotesList() {
+ return ListView.builder(
+ itemBuilder: (_context, index) => noteItemView(notes[index], index),
+ itemCount: notes.length,
+ );
+ }
+
+ void insertNewNote() {
+ notes.add(NoteModel('New note ${notes.length}'));
+ notestobesaved.add(NoteModel('New note ${notes.length}').content);
+ setState(() {});
+ }
+
+ void openNewNote({NoteModel? noteModel}) {
+ NoteModel _note = noteModel ?? NoteModel('');
+ Navigator.push(
+ context,
+ MaterialPageRoute(builder: (context) => NewNotePage(_note)),
+ ).then((value) async {
+ if (noteModel == null) {
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ notestobesaved.add(_note.content);
+ notes.add(_note);
+ await prefs.setStringList('notes', notestobesaved);
+ }
+ setState(() {});
+ });
+ }
+
@override
- Widget build(BuildContext context) {
- var contacts = [
- Contact(
- 'https://i.pravatar.cc/300',
- 'Ahmed',
- '71766137347',
- DateTime.now().add(
- const Duration(seconds: 3),
- ),
- true,
- ),
- Contact(
- 'https://i.pravatar.cc/301',
- 'Ali',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 1),
- ),
- false,
- ),
- Contact(
- 'https://i.pravatar.cc/302',
- 'Kamal',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 3),
- ),
- true,
- ),
- Contact(
- 'https://i.pravatar.cc/303',
- 'Mohammad',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 5),
- ),
- true,
- ),
- Contact(
- 'https://i.pravatar.cc/304',
- 'Mohammad',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 5),
- ),
- false,
- ),
- Contact(
- 'https://i.pravatar.cc/305',
- 'Hussein',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 6),
- ),
- false,
- ),
- Contact(
- 'https://i.pravatar.cc/306',
- 'Aboud',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 7),
- ),
- false,
- ),
- Contact(
- 'https://i.pravatar.cc/307',
- 'Osama',
- '71766137347',
- DateTime.now().add(
- const Duration(days: 6),
- ),
- false,
- ),
- ];
+ void initState() {
+ super.initState();
+ getnotes();
+ }
+
+ void getnotes() async {
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ notestobesaved = (prefs.getStringList('notes') ?? []);
+ for (int i = 0; i < notestobesaved.length; i++) {
+ notes.add(NoteModel(notestobesaved[i]));
+ }
+ setState(() {});
+ }
+
+ @override
+ Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: Text(widget.title),
+ title: Text('notes app'),
),
- body: ListView.builder(
- itemBuilder: (_context, index) {
- return buildContactItem(contacts[index]);
- },
- itemCount: contacts.length,
+ body: buildNotesList(),
+ floatingActionButton: FloatingActionButton(
+ onPressed: openNewNote,
+ child: const Icon(Icons.add),
),
);
}
diff --git a/lib/models/contact.dart b/lib/models/contact.dart
new file mode 100644
index 0000000..31b50e2
--- /dev/null
+++ b/lib/models/contact.dart
@@ -0,0 +1,10 @@
+
+class Contact {
+ String image;
+ String name;
+ String mobileNumber;
+ DateTime date;
+ bool isIncoming;
+
+ Contact(this.image, this.name, this.mobileNumber, this.date, this.isIncoming);
+}
\ No newline at end of file
diff --git a/lib/models/note.dart b/lib/models/note.dart
new file mode 100644
index 0000000..4cac359
--- /dev/null
+++ b/lib/models/note.dart
@@ -0,0 +1,4 @@
+class NoteModel {
+ NoteModel(this.content);
+ String content;
+}
\ No newline at end of file
diff --git a/lib/ui/contact_item_view.dart b/lib/ui/contact_item_view.dart
new file mode 100644
index 0000000..02eb7e5
--- /dev/null
+++ b/lib/ui/contact_item_view.dart
@@ -0,0 +1,46 @@
+
+import 'package:contacts_01/models/contact.dart';
+import 'package:flutter/material.dart';
+
+Widget buildContactItem(Contact _contact) {
+ return Card(
+ child: Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: Row(
+ children: [
+ CircleAvatar(
+ backgroundImage: NetworkImage(_contact.image),
+ ),
+ Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ _contact.name,
+ style: const TextStyle(fontWeight: FontWeight.bold),
+ ),
+ Text(_contact.mobileNumber),
+ ],
+ ),
+ ),
+ Text(_contact.date.toIso8601String().split('T').first),
+ Expanded(
+ child: Container(),
+ ),
+ if (_contact.isIncoming)
+ Icon(
+ Icons.arrow_downward,
+ color: Colors.red,
+ )
+ else
+ Icon(
+ Icons.arrow_upward,
+ color: Colors.green,
+ )
+ ],
+ ),
+ ),
+ );
+}
diff --git a/lib/ui/contacts_list.dart b/lib/ui/contacts_list.dart
new file mode 100644
index 0000000..54cce98
--- /dev/null
+++ b/lib/ui/contacts_list.dart
@@ -0,0 +1,15 @@
+
+
+import 'package:flutter/material.dart';
+
+import '../data.dart';
+import 'contact_item_view.dart';
+
+Widget buildContactsList() {
+ return ListView.builder(
+ itemBuilder: (_context, index) {
+ return buildContactItem(contacts[index]);
+ },
+ itemCount: contacts.length,
+ );
+}
diff --git a/lib/ui/ig_grid_view.dart b/lib/ui/ig_grid_view.dart
new file mode 100644
index 0000000..3e37733
--- /dev/null
+++ b/lib/ui/ig_grid_view.dart
@@ -0,0 +1,35 @@
+
+import 'package:flutter/material.dart';
+import 'dart:math' as math;
+import '../data.dart';
+
+Widget buildFavoritesGridView() {
+ return Column(
+ children: [
+ Text('Favorites'),
+ Divider(
+ thickness: 4,
+ ),
+ Expanded(
+ child: GridView.count(
+ crossAxisCount: 3,
+ children: List.generate(5, (index) {
+ var personColor = Color((math.Random().nextDouble() * 0xFFFFFF).toInt()).withOpacity(1.0);
+ return Center(
+ child: Container(
+ width: 120,
+ height: 120,
+ child: Text(
+ contacts[index].name[0],
+ style: TextStyle(fontSize: 40),
+ ),
+ alignment: Alignment.center,
+ decoration: BoxDecoration(shape: BoxShape.circle, color: personColor),
+ ),
+ );
+ }),
+ ),
+ ),
+ ],
+ );
+}
diff --git a/lib/ui/new_note_page.dart b/lib/ui/new_note_page.dart
new file mode 100644
index 0000000..adab522
--- /dev/null
+++ b/lib/ui/new_note_page.dart
@@ -0,0 +1,40 @@
+import 'package:contacts_01/models/note.dart';
+import 'package:flutter/material.dart';
+
+class NewNotePage extends StatefulWidget {
+ NewNotePage(this.noteModel);
+
+ final NoteModel noteModel;
+
+ @override
+ State createState() => _NewNotePageState();
+}
+
+class _NewNotePageState extends State {
+ var _controller = TextEditingController();
+
+ @override
+ void initState() {
+ _controller.text = widget.noteModel.content;
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(),
+ body: TextField(
+ autofocus: true,
+ keyboardType: TextInputType.multiline,
+ maxLines: null,
+ controller: _controller,
+ onSubmitted: (s) {
+
+ },
+ onChanged: (s) {
+ widget.noteModel.content = _controller.text;
+ debugPrint('s: $s');
+ },
+ ));
+ }
+}
diff --git a/lib/ui/second_page.dart b/lib/ui/second_page.dart
new file mode 100644
index 0000000..dba310a
--- /dev/null
+++ b/lib/ui/second_page.dart
@@ -0,0 +1,10 @@
+import 'package:flutter/material.dart';
+
+class SecondPage extends StatelessWidget {
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(),
+ body: Center(child: Text('Second page')));
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
index 750761f..b4d4b8c 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -57,6 +57,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
+ ffi:
+ dependency: transitive
+ description:
+ name: ffi
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.1.2"
+ file:
+ dependency: transitive
+ description:
+ name: file
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
@@ -69,11 +83,30 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
+ flutter_svg:
+ dependency: "direct main"
+ description:
+ name: flutter_svg
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.22.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
+ flutter_web_plugins:
+ dependency: transitive
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ js:
+ dependency: transitive
+ description:
+ name: js
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.6.3"
lints:
dependency: transitive
description:
@@ -102,6 +135,111 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
+ path_drawing:
+ dependency: transitive
+ description:
+ name: path_drawing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.5.1"
+ path_parsing:
+ dependency: transitive
+ description:
+ name: path_parsing
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.1"
+ path_provider_linux:
+ dependency: transitive
+ description:
+ name: path_provider_linux
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.1.0"
+ path_provider_platform_interface:
+ dependency: transitive
+ description:
+ name: path_provider_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.1"
+ path_provider_windows:
+ dependency: transitive
+ description:
+ name: path_provider_windows
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.3"
+ petitparser:
+ dependency: transitive
+ description:
+ name: petitparser
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "4.3.0"
+ platform:
+ dependency: transitive
+ description:
+ name: platform
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.0.2"
+ plugin_platform_interface:
+ dependency: transitive
+ description:
+ name: plugin_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.2"
+ process:
+ dependency: transitive
+ description:
+ name: process
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "4.2.3"
+ shared_preferences:
+ dependency: "direct main"
+ description:
+ name: shared_preferences
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.8"
+ shared_preferences_linux:
+ dependency: transitive
+ description:
+ name: shared_preferences_linux
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.2"
+ shared_preferences_macos:
+ dependency: transitive
+ description:
+ name: shared_preferences_macos
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.2"
+ shared_preferences_platform_interface:
+ dependency: transitive
+ description:
+ name: shared_preferences_platform_interface
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.0"
+ shared_preferences_web:
+ dependency: transitive
+ description:
+ name: shared_preferences_web
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.2"
+ shared_preferences_windows:
+ dependency: transitive
+ description:
+ name: shared_preferences_windows
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.2"
sky_engine:
dependency: transitive
description: flutter
@@ -163,5 +301,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
+ win32:
+ dependency: transitive
+ description:
+ name: win32
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.2.9"
+ xdg_directories:
+ dependency: transitive
+ description:
+ name: xdg_directories
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.2.0"
+ xml:
+ dependency: transitive
+ description:
+ name: xml
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "5.3.0"
sdks:
- dart: ">=2.12.0 <3.0.0"
+ dart: ">=2.14.0 <3.0.0"
+ flutter: ">=2.5.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 1c93cc7..29f7b0a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -34,6 +34,8 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
+ flutter_svg: ^0.22.0
+ shared_preferences: ^2.0.8
dev_dependencies:
flutter_test:
@@ -58,9 +60,8 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
+ assets:
+ - images/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
@@ -73,17 +74,12 @@ flutter:
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
+ fonts:
+ - family: Tajawal
+ fonts:
+ - asset: fonts/Tajawal/Tajawal-Regular.ttf
+ - asset: fonts/Tajawal/Tajawal-Bold.ttf
+ weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages