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/lib/home.dart b/lib/home.dart new file mode 100644 index 0000000..4fac47c --- /dev/null +++ b/lib/home.dart @@ -0,0 +1,112 @@ +import 'package:contacts_01/models/db_conn.dart'; +import 'package:contacts_01/models/note.dart'; +import 'package:contacts_01/ui/edit_note.dart'; +import 'package:flutter/material.dart'; +import 'models/note_model.dart'; +import 'models/note.dart'; + +class NotesPage extends StatefulWidget { + const NotesPage({Key? key, required this.title}) : super(key: key); + + final String title; + + @override + _NotesPageState createState() => _NotesPageState(); +} + +class _NotesPageState extends State { + List notes = []; + bool _isloading = false; + + @override + void initState() { + refreshNotes(); + super.initState(); + } + + @override + void dispose() { + NotesDatabase.instance.close(); + + super.dispose(); + } + + Future refreshNotes() async { + setState(() => _isloading = true); + notes = await NotesDatabase.instance.readAllNote(); + setState(() => _isloading = false); + } + + @override + Widget build(BuildContext context) { + return DefaultTabController( + length: 2, + child: Scaffold( + backgroundColor: Colors.blueGrey.shade50, + appBar: AppBar( + backgroundColor: Colors.blueGrey.shade100, + elevation: 0, + title: Text( + widget.title, + style: const TextStyle( + color: Colors.black87, + fontSize: 24, + fontWeight: FontWeight.w900), + ), + bottom: const TabBar( + labelColor: Colors.blueAccent, + indicatorColor: Colors.amber, + tabs: [ + Tab(icon: Icon(Icons.horizontal_split)), + Tab(icon: Icon(Icons.assignment_turned_in)), + ], + ), + ), + body: _isloading + ? const Center(child: CircularProgressIndicator()) + : notes.isEmpty + ? const Center( + child: Text( + 'No Notes', + style: TextStyle(color: Colors.blueAccent, fontSize: 24), + ), + ) + : TabBarView( + children: [noteListBuilder(), checkedNotesBuilder()], + ), + floatingActionButton: FloatingActionButton( + backgroundColor: Colors.blueGrey.shade100, + onPressed: createNewNote, + child: const Icon( + Icons.add, + color: Colors.blueAccent, + ), + ), + ), + ); + } + + void createNewNote() async { + await Navigator.of(context).push( + MaterialPageRoute(builder: (context) => const AddEditNotePage()), + ); + + refreshNotes(); + } + + noteListBuilder() { + refreshNotes(); + return ListView.builder( + itemCount: notes.length, + itemBuilder: (_context, index) => noteItemView(notes[index], context), + ); + } + + checkedNotesBuilder() { + refreshNotes(); + return ListView.builder( + itemCount: notes.length, + itemBuilder: (_context, index) => checkedNoteItem(notes[index], context), + ); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index 2c084ed..c2625c2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,255 +1,20 @@ import 'package:flutter/material.dart'; -import 'dart:math' as math; +import 'home.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', - theme: ThemeData( - primarySwatch: Colors.blue, - ), + title: 'Notes App', + theme: ThemeData(fontFamily: 'Tajawal'), debugShowCheckedModeBanner: false, - home: const MyHomePage(title: 'Contacts App'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({Key? key, required this.title}) : super(key: key); - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _selectedIndex = 2; - static const TextStyle optionStyle = - TextStyle(fontSize: 30, fontWeight: FontWeight.bold); - static late List _pages; - - _MyHomePageState() { - _pages = [ - buildContactsList(), - buildFavoritesGridView(), - // Text('hello'), - Text( - 'Index 2: School', - style: optionStyle, - ), - ]; - } - - void _onItemTapped(int index) { - setState(() { - _selectedIndex = index; - }); - } - - 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, - ), - ]; - - 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), - ), - ); - }), - ), - ), - ], - ); - } - - 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, - ) - ], - ), - ), - ); - } - - Widget buildContactsList() { - return ListView.builder( - itemBuilder: (_context, index) { - return buildContactItem(contacts[index]); - }, - itemCount: contacts.length, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(widget.title), - ), - body: Center( - child: _pages[_selectedIndex], - ), - bottomNavigationBar: BottomNavigationBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.home), - label: 'Recent', - ), - BottomNavigationBarItem( - icon: Icon(Icons.favorite), - label: 'Favorites', - ), - BottomNavigationBarItem( - icon: Icon(Icons.access_time_outlined), - label: 'School', - activeIcon: Icon(Icons.access_time_filled) - ), - ], - currentIndex: _selectedIndex, - selectedItemColor: Colors.amber[800], - onTap: _onItemTapped, - ), + home: const NotesPage(title: 'Notes App'), ); } } diff --git a/lib/models/db_conn.dart b/lib/models/db_conn.dart new file mode 100644 index 0000000..7b337bb --- /dev/null +++ b/lib/models/db_conn.dart @@ -0,0 +1,89 @@ +import 'package:contacts_01/models/note_model.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:path/path.dart'; + +class NotesDatabase { + static final NotesDatabase instance = NotesDatabase._init(); + static Database? _database; + NotesDatabase._init(); + Future get database async { + if (_database != null) return _database!; + _database = await _initDB('notes.db'); + return _database!; + } + + Future _initDB(String filePath) async { + final dbPath = await getDatabasesPath(); + final path = join(dbPath, filePath); + + return await openDatabase(path, version: 1, onCreate: _createDB); + } + + Future _createDB(Database db, int version) async { + const idType = 'INTEGER PRIMARY KEY AUTOINCREMENT'; + const textType = 'TEXT NOT NULL'; + const boolType = 'BOOLEAN NOT NULL'; + + await db.execute(''' + CREATE TABLE $tableNotes ( + ${NoteFields.id} $idType, + ${NoteFields.content} $textType, + ${NoteFields.initDate} $textType, + ${NoteFields.isFinished} $boolType + ) + '''); + } + + Future create(NoteModel note) async { + final db = await instance.database; + final id = await db.insert(tableNotes, note.toJson()); + return note.copy(id: id); + } + + Future readNote(int id) async { + final db = await instance.database; + final maps = await db.query( + tableNotes, + columns: NoteFields.values, + where: '${NoteFields.id}=?', + whereArgs: [id], + ); + if (maps.isNotEmpty) { + return NoteModel.fromJson(maps.first); + } else { + throw Exception('ID $id NOT FOUND'); + } + } + + Future> readAllNote() async { + final db = await instance.database; + final orderDESC = '${NoteFields.initDate} DESC'; + final result = await db.query(tableNotes, orderBy: orderDESC); + return result.map((json) => NoteModel.fromJson(json)).toList(); + } + + Future update(NoteModel note) async { + final db = await instance.database; + return db.update( + tableNotes, + note.toJson(), + where: '${NoteFields.id}=?', + whereArgs: [note.id], + ); + } + + Future delete(int id) async { + final db = await instance.database; + return db.delete( + tableNotes, + where: '${NoteFields.id}=?', + whereArgs: [id], + ); + } + + Future close() async { + final db = await instance.database; + + db.close(); + } +} diff --git a/lib/models/note.dart b/lib/models/note.dart new file mode 100644 index 0000000..dcf7658 --- /dev/null +++ b/lib/models/note.dart @@ -0,0 +1,125 @@ +import 'package:contacts_01/models/db_conn.dart'; +import 'package:contacts_01/models/note_model.dart'; +import 'package:contacts_01/ui/edit_note.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +Widget noteItemView(NoteModel note, BuildContext context) { + if (note.isFinished == false) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + color: Colors.white, + shape: RoundedRectangleBorder( + side: const BorderSide(color: Colors.blueAccent), + borderRadius: BorderRadius.circular(15.0), + ), + child: InkWell( + onTap: () async { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => AddEditNotePage(note: note)), + ); + }, + child: Padding( + padding: const EdgeInsets.all(20), + child: Container( + color: Colors.transparent, + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + note.content, + maxLines: 1, + softWrap: false, + overflow: TextOverflow.ellipsis, + style: const TextStyle(fontSize: 20), + ), + Text( + dateSet(note), + style: const TextStyle( + fontSize: 20, color: Colors.blueAccent), + ), + ], + ), + Expanded( + child: Container(), + ), + ], + ), + ), + ), + ), + ), + ); + } else { + return Container(); + } +} + +Widget checkedNoteItem(NoteModel note, BuildContext context) { + if (note.isFinished == true) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + color: Colors.white, + shape: RoundedRectangleBorder( + side: const BorderSide(color: Colors.blueAccent), + borderRadius: BorderRadius.circular(15.0), + ), + child: InkWell( + onTap: () async { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => AddEditNotePage(note: note)), + ); + }, + child: Padding( + padding: const EdgeInsets.all(20), + child: Container( + color: Colors.transparent, + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + note.content, + maxLines: 1, + softWrap: false, + overflow: TextOverflow.ellipsis, + style: const TextStyle(fontSize: 20), + ), + Text( + dateSet(note), + style: const TextStyle( + fontSize: 20, color: Colors.blueAccent), + ), + ], + ), + Expanded( + child: Container(), + ), + ], + ), + ), + ), + ), + ), + ); + } else { + return Container(); + } +} + +String dateSet(NoteModel note) { + var date = note.initDate; + String formattedDate = DateFormat('yyyy-MM-dd H:m').format(date); + return formattedDate; +} + +addNote(NoteModel note) async { + await NotesDatabase.instance.create(note); +} diff --git a/lib/models/note_model.dart b/lib/models/note_model.dart new file mode 100644 index 0000000..cd121e4 --- /dev/null +++ b/lib/models/note_model.dart @@ -0,0 +1,53 @@ +const String tableNotes = 'notes'; + +class NoteFields { + static final List values = [ + id, + content, + initDate, + isFinished + ]; + + static const String id = '_id'; + static const String content = 'content'; + static const String initDate = 'initDate'; + static const String isFinished = 'isFinished'; +} + +class NoteModel { + NoteModel( + {this.id, + required this.content, + required this.initDate, + required this.isFinished}); + int? id; + String content; + DateTime initDate; + bool isFinished; + + NoteModel copy({ + int? id, + String? content, + DateTime? initDate, + bool? isFinished, + }) => + NoteModel( + id: id ?? this.id, + content: content ?? this.content, + initDate: initDate ?? this.initDate, + isFinished: isFinished ?? this.isFinished); + + static NoteModel fromJson(Map json) => NoteModel( + id: json[NoteFields.id] as int, + content: json[NoteFields.content] as String, + initDate: DateTime.parse(json[NoteFields.initDate] as String), + isFinished: json[NoteFields.isFinished] == 1, + ); + + Map toJson() => { + NoteFields.id: id, + NoteFields.content: content, + NoteFields.initDate: initDate.toIso8601String(), + NoteFields.isFinished: isFinished ? 1 : 0, + }; +} diff --git a/lib/ui/edit_note.dart b/lib/ui/edit_note.dart new file mode 100644 index 0000000..b6d3b14 --- /dev/null +++ b/lib/ui/edit_note.dart @@ -0,0 +1,106 @@ +import 'package:contacts_01/models/db_conn.dart'; +import 'package:contacts_01/models/note_model.dart'; +import 'package:contacts_01/widget/note_form.dart'; +import 'package:flutter/material.dart'; + +class AddEditNotePage extends StatefulWidget { + final NoteModel? note; + + const AddEditNotePage({ + Key? key, + this.note, + }) : super(key: key); + @override + _AddEditNotePageState createState() => _AddEditNotePageState(); +} + +class _AddEditNotePageState extends State { + final _formKey = GlobalKey(); + late bool isFinished; + late int id; + late String content; + late DateTime initDate; + + @override + void initState() { + super.initState(); + + isFinished = widget.note?.isFinished ?? false; + content = widget.note?.content ?? ''; + id = widget.note?.id ?? 0; + } + + @override + Widget build(BuildContext context) => Scaffold( + backgroundColor: Colors.blueGrey.shade50, + appBar: AppBar( + foregroundColor: Colors.blueAccent, + backgroundColor: Colors.blueGrey.shade100, + elevation: 0, + actions: [widget.note != null? + IconButton( + onPressed: () async { + await NotesDatabase.instance.delete(id); + + Navigator.of(context).pop(); + }, + icon: const Icon(Icons.delete), + ):Container(), + ], + ), + body: Form( + key: _formKey, + child: NoteFormWidget( + isFinished: isFinished, + content: content, + onChangedFinished: (isFinished) => + setState(() => this.isFinished = isFinished), + onChangedcontent: (content) => + setState(() => this.content = content), + ), + ), + floatingActionButton: FloatingActionButton( + backgroundColor: Colors.blueGrey.shade100, + onPressed: addOrUpdateNote, + child: const Icon( + Icons.check, + color: Colors.blueAccent, + size: 25, + )), + ); + + void addOrUpdateNote() async { + final isValid = _formKey.currentState!.validate(); + + if (isValid) { + final isUpdating = widget.note != null; + + if (isUpdating) { + await updateNote(); + } else { + await addNote(); + } + + Navigator.of(context).pop(); + } + } + + Future updateNote() async { + final note = widget.note!.copy( + isFinished: isFinished, + content: content, + ); + + await NotesDatabase.instance.update(note); + } + + Future addNote() async { + final note = NoteModel( + content: content, + isFinished: false, + initDate: DateTime.now(), + ); + + await NotesDatabase.instance.create(note); + } +} diff --git a/lib/widget/note_form.dart b/lib/widget/note_form.dart new file mode 100644 index 0000000..1608e57 --- /dev/null +++ b/lib/widget/note_form.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; + +class NoteFormWidget extends StatelessWidget { + final bool? isFinished; + final String? content; + final ValueChanged onChangedFinished; + final ValueChanged onChangedcontent; + + const NoteFormWidget({ + Key? key, + this.isFinished = false, + this.content = '', + required this.onChangedFinished, + required this.onChangedcontent, + }) : super(key: key); + + @override + Widget build(BuildContext context) => SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + buildTitle(), + const SizedBox(height: 30), + Container( + width: 220, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.0), + color: Colors.blueGrey.shade100, + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'Not done', + style: TextStyle( + color: Colors.black87, + fontSize: 16, + ), + ), + Switch( + value: isFinished ?? false, + onChanged: onChangedFinished, + activeColor: Colors.amberAccent, + activeTrackColor: Colors.blueAccent, + inactiveThumbColor: Colors.amberAccent, + ), + const Text( + 'Done', + style: TextStyle( + color: Colors.black87, + fontSize: 16, + ), + ), + ], + ), + ), + ], + ), + ), + ); + + Widget buildTitle() => TextFormField( + maxLines: 3, + initialValue: content, + style: const TextStyle( + color: Colors.black87, + fontSize: 22, + ), + decoration: InputDecoration( + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(15), + ), + filled: true, + fillColor: Colors.white, + hintText: 'Type your note', + hintStyle: const TextStyle(color: Colors.black87), + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide(color: Colors.blueAccent, width: 2.0), + borderRadius: BorderRadius.circular(25.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(color: Colors.blueAccent, width: 2.0), + borderRadius: BorderRadius.circular(25.0), + ), + errorBorder: OutlineInputBorder( + borderSide: const BorderSide(color: Colors.redAccent, width: 2.0), + borderRadius: BorderRadius.circular(25.0), + ), + ), + validator: (content) => content != null && content.isEmpty + ? 'The Note cannot be empty' + : null, + onChanged: onChangedcontent, + ); +} diff --git a/pubspec.lock b/pubspec.lock index 750761f..2472a8b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -69,11 +69,25 @@ 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" + intl: + dependency: "direct main" + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" lints: dependency: transitive description: @@ -96,12 +110,33 @@ packages: source: hosted version: "1.7.0" path: - dependency: transitive + dependency: "direct main" description: name: path 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" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "4.3.0" sky_engine: dependency: transitive description: flutter @@ -114,6 +149,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + sqflite: + dependency: "direct main" + description: + name: sqflite + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0+4" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1+1" stack_trace: dependency: transitive description: @@ -135,6 +184,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + synchronized: + dependency: transitive + description: + name: synchronized + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" term_glyph: dependency: transitive description: @@ -163,5 +219,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.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: ">=1.24.0-7.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1c93cc7..0312bfd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,10 @@ 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 + intl: ^0.17.0 + sqflite: ^2.0.0+4 + path: ^1.8.0 dev_dependencies: flutter_test: @@ -58,9 +62,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 +76,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