-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f891ad5
commit 84e8cf4
Showing
32 changed files
with
1,368 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"git.ignoreLimitWarning": true | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
const Color kPrimaryColor = Color(0xff62FCD7); | ||
const kNotesBox = 'notes_box'; | ||
const List<Color> kcolors = [ | ||
Color(0xffAC3931), | ||
Color(0xffE5D352), | ||
Color(0xffD9E76C), | ||
Color(0xff537D8D), | ||
Color(0xff482C3d), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:bloc/bloc.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:hive_flutter/adapters.dart'; | ||
import 'package:note_app/constants.dart'; | ||
import 'package:note_app/models/note_model.dart'; | ||
|
||
part 'add_note_state.dart'; | ||
|
||
class AddNoteCubit extends Cubit<AddNoteState> { | ||
AddNoteCubit() : super(AddNoteInitial()); | ||
Color color = const Color(0xffAC3931); | ||
addnote(NoteModel note) async { | ||
emit(AddNoteLoading()); | ||
note.color = color.value; | ||
try { | ||
var notebox = Hive.box<NoteModel>(kNotesBox); | ||
await notebox.add(note); | ||
emit(AddNoteSuccess()); | ||
} catch (e) { | ||
emit(AddNoteFailure(e.toString())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
part of 'add_note_cubit.dart'; | ||
|
||
@immutable | ||
abstract class AddNoteState {} | ||
|
||
class AddNoteInitial extends AddNoteState {} | ||
|
||
class AddNoteLoading extends AddNoteState {} | ||
|
||
class AddNoteSuccess extends AddNoteState {} | ||
|
||
class AddNoteFailure extends AddNoteState { | ||
final String errMessage; | ||
AddNoteFailure(this.errMessage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:bloc/bloc.dart'; | ||
import 'package:hive_flutter/adapters.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
import '../../constants.dart'; | ||
import '../../models/note_model.dart'; | ||
|
||
part 'notes_state.dart'; | ||
|
||
class NotesCubit extends Cubit<NotesState> { | ||
NotesCubit() : super(NotesInitial()); | ||
|
||
List<NoteModel>? notes; | ||
FetchAllNodes() { | ||
var notebox = Hive.box<NoteModel>(kNotesBox); | ||
notes = notebox.values.toList(); | ||
emit(Notesuccess()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
part of 'notes_cubit.dart'; | ||
|
||
@immutable | ||
abstract class NotesState {} | ||
|
||
class NotesInitial extends NotesState {} | ||
|
||
class Notesuccess extends NotesState {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:hive_flutter/adapters.dart'; | ||
part 'note_model.g.dart'; | ||
|
||
@HiveType(typeId: 0) | ||
class NoteModel extends HiveObject { | ||
@HiveField(0) | ||
String title; | ||
@HiveField(1) | ||
String content; | ||
@HiveField(2) | ||
final String date; | ||
@HiveField(3) | ||
int color; | ||
|
||
NoteModel({ | ||
required this.title, | ||
required this.content, | ||
required this.date, | ||
required this.color, | ||
}); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
class SimpleBlocObserver implements BlocObserver { | ||
@override | ||
void onChange(BlocBase bloc, Change change) { | ||
debugPrint('change = ${change}'); | ||
} | ||
|
||
@override | ||
void onClose(BlocBase bloc) { | ||
debugPrint('Close = ${bloc}'); | ||
} | ||
|
||
@override | ||
void onCreate(BlocBase bloc) { | ||
debugPrint('Create = ${bloc}'); | ||
} | ||
|
||
@override | ||
void onError(BlocBase bloc, Object error, StackTrace stackTrace) { | ||
debugPrint('Error = ${bloc}'); | ||
} | ||
|
||
@override | ||
void onEvent(Bloc bloc, Object? event) { | ||
debugPrint('Event = ${bloc}'); | ||
} | ||
|
||
@override | ||
void onTransition(Bloc bloc, Transition transition) { | ||
debugPrint('Transition = ${bloc}'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:note_app/models/note_model.dart'; | ||
import 'package:note_app/views/widgets/edit_note_view_body.dart'; | ||
|
||
class EditNotesView extends StatelessWidget { | ||
const EditNotesView({super.key, required this.note}); | ||
final NoteModel note; | ||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea( | ||
child: Scaffold( | ||
body: EditNotesViewBody(note: note), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:note_app/cubit/notes_cubit/notes_cubit.dart'; | ||
import 'package:note_app/views/widgets/add_note_botton_shett.dart'; | ||
import 'package:note_app/views/widgets/note_view_body.dart'; | ||
|
||
class NotesView extends StatelessWidget { | ||
const NotesView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea( | ||
child: Scaffold( | ||
floatingActionButton: FloatingActionButton( | ||
child: Icon(Icons.add), | ||
onPressed: () { | ||
showModalBottomSheet( | ||
isScrollControlled: true, | ||
shape: RoundedRectangleBorder( | ||
borderRadius: BorderRadius.circular(16), | ||
), | ||
context: context, | ||
builder: (context) => const AddButtonSheet()); | ||
}, | ||
), | ||
body: NotesViewBody(), | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// ignore_for_file: non_constant_identifier_names | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; | ||
import 'package:note_app/constants.dart'; | ||
|
||
class CustomButton extends StatelessWidget { | ||
String Titel; | ||
VoidCallback? onTap; | ||
bool? isLoading = false; | ||
CustomButton({super.key, required this.Titel, this.onTap, this.isLoading}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
onTap: onTap, | ||
child: Container( | ||
decoration: BoxDecoration(color: kPrimaryColor, borderRadius: BorderRadius.circular(8)), | ||
width: double.infinity, | ||
height: 60, | ||
child: Center( | ||
child: isLoading == true | ||
?const SizedBox( | ||
width: 24, | ||
height: 24, | ||
child: CircularProgressIndicator( | ||
color: Colors.black, | ||
), | ||
) | ||
: Text( | ||
'$Titel', | ||
style:const TextStyle( | ||
color: Colors.black, | ||
fontSize: 25, | ||
fontWeight: FontWeight.bold, | ||
), | ||
)), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; | ||
import 'package:note_app/cubit/add_note_cubit/add_note_cubit.dart'; | ||
import 'package:note_app/cubit/notes_cubit/notes_cubit.dart'; | ||
import 'package:note_app/views/widgets/CustomButton.dart'; | ||
import 'package:note_app/views/widgets/custom_text_field.dart'; | ||
|
||
import 'add_note_form.dart'; | ||
|
||
class AddButtonSheet extends StatelessWidget { | ||
const AddButtonSheet({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return BlocProvider( | ||
create: (context) => AddNoteCubit(), | ||
child: BlocConsumer<AddNoteCubit, AddNoteState>( | ||
listener: (context, state) { | ||
if (state is AddNoteFailure) { | ||
debugPrint('error ${state.errMessage}'); | ||
} | ||
if (state is AddNoteSuccess) { | ||
Navigator.pop(context); | ||
BlocProvider.of<NotesCubit>(context).FetchAllNodes(); | ||
} | ||
}, | ||
builder: (context, state) { | ||
return AbsorbPointer( | ||
absorbing: state is AddNoteLoading ? true : false, | ||
child: Padding( | ||
padding: EdgeInsets.only( | ||
left: 16, | ||
right: 16, | ||
bottom: MediaQuery.of(context).viewInsets.bottom, | ||
), | ||
child: SingleChildScrollView(child: AddNoteForm()), | ||
), | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.