create note
This commit is contained in:
@@ -1,19 +1,55 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:progetto_m335_flutter/pages/NotesView.dart';
|
||||||
|
|
||||||
class CreateNewNote extends StatefulWidget {
|
class CreateNewNote extends StatefulWidget {
|
||||||
const CreateNewNote({super.key});
|
const CreateNewNote({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CreateNewNote> createState() => _CreateNewNoteState();
|
State<CreateNewNote> createState() => _CreateNewNoteState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CreateNewNoteState extends State<CreateNewNote> {
|
class _CreateNewNoteState extends State<CreateNewNote> {
|
||||||
|
TextEditingController _titleController = TextEditingController();
|
||||||
|
TextEditingController _textController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_titleController.dispose();
|
||||||
|
_textController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
appBar: AppBar(
|
||||||
child: Text('CreateNewNote'),
|
title: Text('Create New Note'),
|
||||||
)
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('Title:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
|
||||||
|
TextField(controller: _titleController, decoration: InputDecoration(hintText: 'Enter a title',),),
|
||||||
|
SizedBox(height: 16), // Spacing between title and text
|
||||||
|
Text('Text:', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),),
|
||||||
|
TextField(controller: _textController, maxLines: null, decoration: InputDecoration(hintText: 'Enter text', border: InputBorder.none,),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
String title = _titleController.text;
|
||||||
|
String text = _textController.text;
|
||||||
|
_titleController.clear();
|
||||||
|
_textController.clear();
|
||||||
|
|
||||||
|
},
|
||||||
|
child: Icon(Icons.save, color: Colors.white,),
|
||||||
|
backgroundColor: Colors.lightBlue.shade900,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ class _NotesViewState extends State<NotesView> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Icon(Icons.add),
|
child: Icon(Icons.add, color: Colors.white,),
|
||||||
backgroundColor: Colors.lightBlue.shade900,
|
backgroundColor: Colors.lightBlue.shade900,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user