This commit is contained in:
2022-10-23 15:50:44 +02:00
commit e71f891e5d
76 changed files with 2320 additions and 0 deletions

116
lib/CollapseDrawer.dart Normal file
View File

@ -0,0 +1,116 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:notes/drawer_item.dart';
enum View {
all, shared, recycle, folders
}
class CollapseDrawer extends StatefulWidget {
const CollapseDrawer({Key? key, required this.onPageChange, required this.activePage}) : super(key: key);
final void Function(View newPage) onPageChange;
final View activePage;
@override
State<CollapseDrawer> createState() => _CollapseDrawerState();
}
class _CollapseDrawerState extends State<CollapseDrawer>
with SingleTickerProviderStateMixin {
bool collapsed = true;
late Animation collapseAnimation;
late AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(
vsync: this, duration: const Duration(milliseconds: 200));
collapseAnimation = Tween<double>(begin: 62, end: 300).animate(controller)
..addListener(() {
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: const BorderRadius.only(
topRight: Radius.circular(10), bottomRight: Radius.circular(10)),
child: Container(
color: const Color.fromRGBO(0, 0, 0, .75),
child: ConstrainedBox(
constraints: BoxConstraints.expand(width: collapseAnimation.value),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
height: 10,
),
Row(
children: [
const SizedBox(
width: 8,
),
IconButton(
onPressed: () {
collapsed ? controller.forward() : controller.reverse();
setState(() => collapsed = !collapsed);
},
icon: const Icon(
Icons.menu,
size: 28,
color: Color.fromRGBO(255, 255, 255, .75),
)),
if (!collapsed) ...[
const Expanded(child: SizedBox()),
IconButton(
onPressed: () {},
icon: const Icon(
Icons.settings_outlined,
size: 26,
color: Color.fromRGBO(255, 255, 255, .55),
)),
const SizedBox(
width: 15,
)
]
],
),
const SizedBox(
height: 40,
),
Expanded(
child: ListView(
children: [
DrawerItem(
dta: ItemData("All Notes", Icons.book),
collapsed: collapsed,
active: widget.activePage == View.all,
onTap: () => widget.onPageChange(View.all)),
DrawerItem(
dta: ItemData("Shared Notebooks", Icons.person_outline),
collapsed: collapsed,
active: widget.activePage == View.shared,
onTap: () => widget.onPageChange(View.shared)),
DrawerItem(
dta: ItemData("Recycle bin", CupertinoIcons.trash),
collapsed: collapsed,
active: widget.activePage == View.recycle,
onTap: () => widget.onPageChange(View.recycle)),
DrawerItem(
dta: ItemData("Folders", Icons.folder_outlined),
collapsed: collapsed,
active: widget.activePage == View.folders,
onTap: () => widget.onPageChange(View.folders)),
],
)),
],
),
),
),
);
}
}

70
lib/all_notes_page.dart Normal file
View File

@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
class AllNotesPage extends StatefulWidget {
const AllNotesPage({Key? key}) : super(key: key);
@override
State<AllNotesPage> createState() => _AllNotesPageState();
}
class _AllNotesPageState extends State<AllNotesPage> {
@override
Widget build(BuildContext context) {
return Column(
children: [
const SizedBox(
height: 10,
),
Row(
children: [
const SizedBox(
width: 20,
),
const Text(
"All notes",
style: TextStyle(
color: Color.fromRGBO(255, 255, 255, .85), fontSize: 22),
),
Expanded(child: Container()),
Material(
color: Colors.transparent,
shape: const CircleBorder(),
clipBehavior: Clip.hardEdge,
child: IconButton(
icon: const Icon(Icons.picture_as_pdf_outlined),
iconSize: 28,
color: const Color.fromRGBO(255, 255, 255, .85),
onPressed: () {},
),
),
Material(
color: Colors.transparent,
shape: const CircleBorder(),
clipBehavior: Clip.hardEdge,
child: IconButton(
icon: const Icon(Icons.search),
iconSize: 28,
color: const Color.fromRGBO(255, 255, 255, .85),
onPressed: () {},
),
),
Material(
color: Colors.transparent,
shape: const CircleBorder(),
clipBehavior: Clip.hardEdge,
child: IconButton(
icon: const Icon(Icons.more_vert),
iconSize: 28,
color: const Color.fromRGBO(255, 255, 255, .85),
onPressed: () {},
),
),
const SizedBox(
width: 15,
)
],
),
],
);
}
}

73
lib/drawer_item.dart Normal file
View File

@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'CollapseDrawer.dart';
class DrawerItem extends StatelessWidget {
const DrawerItem(
{Key? key, required this.dta, this.endText, required this.collapsed, required this.active, required this.onTap})
: super(key: key);
final ItemData dta;
final String? endText;
final bool collapsed;
final bool active;
final void Function() onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.only(left: 9, top: 7, bottom: 7, right: 9),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
color: active ? const Color.fromRGBO(255,255,255,.25) : Colors.transparent,
child: Padding(
padding: const EdgeInsets.only(left: 9, top: 7, bottom: 7, right: 9),
child: Row(
children: [
Icon(
dta.icon,
size: 26,
color: const Color.fromRGBO(255, 255, 255, .75),
),
if (!collapsed) ...[
const SizedBox(
width: 10,
),
Text(
dta.name,
style:
const TextStyle(color: Color.fromRGBO(255, 255, 255, .85)),
),
Expanded(child: Container()),
Text(
endText ?? "",
style:
const TextStyle(color: Color.fromRGBO(255, 255, 255, .45)),
),
const SizedBox(
width: 15,
)
]
],
),
),
),
),
),
);
}
}
class ItemData {
String name;
IconData icon;
ItemData(this.name, this.icon);
@override
String toString() {
return 'ItemData{name: $name, icon: $icon}';
}
}

68
lib/main.dart Normal file
View File

@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:notes/CollapseDrawer.dart';
import 'package:notes/all_notes_page.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// is not restarted.
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
View activePage = View.all;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
children: [
CollapseDrawer(
onPageChange: (View newPage) =>
setState(() => activePage = newPage), activePage: activePage,),
Expanded(
child: Container(
color: const Color.fromRGBO(0, 0, 0, .95),
child: _buildPage(),
))
],
),
);
}
Widget _buildPage() {
switch (activePage) {
case View.all:
return const AllNotesPage();
case View.shared:
return const Text("Todo1", style: TextStyle(color: Colors.white),);
case View.recycle:
return const Text("Todo", style: TextStyle(color: Colors.white),);
case View.folders:
return const Text("Todo", style: TextStyle(color: Colors.white),);
}
}
}