Skip to content

Commit

Permalink
Merge pull request #3 from mrunix00/new-note-screen
Browse files Browse the repository at this point in the history
Add new note screen
  • Loading branch information
abdelillahbel committed Nov 24, 2023
2 parents 49abd98 + 29bf858 commit 0ff8ef7
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 22 deletions.
10 changes: 10 additions & 0 deletions assets/back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions lib/core/go_router.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:go_router/go_router.dart';
import 'package:noteapp/screens/new_note_screen.dart';

import '../screens/home_screen.dart';

GoRouter appRouter = GoRouter(
initialLocation: '/',
routes: [
GoRoute(
path: '/',
redirect: (_, __) => '/HomeScreen',
),
GoRoute(
path: '/HomeScreen',
builder: (context, state) => const HomeScreen(),
),
GoRoute(
path: '/NewNote',
builder: (context, state) => const NewNoteScreen(),
),
],
);
17 changes: 14 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'notes_app.dart';
import 'core/go_router.dart';
import 'theme.dart';

void main() {
runApp(const NotesApp());
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(systemNavigationBarColor: Color(0xff252525)),
);
runApp(
MaterialApp.router(
title: 'Notes',
theme: themeData,
routerConfig: appRouter,
),
);
}

17 changes: 0 additions & 17 deletions lib/notes_app.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/screens/about_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ class AboutNotesAppDialog extends StatelessWidget {
),
);
}
}
}
5 changes: 4 additions & 1 deletion lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
import 'package:noteapp/widgets/square_icon_button.dart';

import 'about_dialog.dart';
Expand Down Expand Up @@ -42,7 +43,9 @@ class HomeScreen extends StatelessWidget {
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
onPressed: () {
context.push('/NewNote');
},
child: SvgPicture.asset("assets/add.svg"),
),
);
Expand Down
57 changes: 57 additions & 0 deletions lib/screens/new_note_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:noteapp/widgets/square_icon_button.dart';

import '../widgets/go_back_button.dart';

class NewNoteScreen extends StatelessWidget {
const NewNoteScreen({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leadingWidth: 75,
leading: const GoBackButton(),
actions: [
SquareIconButton(
icon: const Icon(Icons.visibility_outlined),
onPressed: () {},
),
const SizedBox(width: 25),
SquareIconButton(
icon: const Icon(Icons.save_outlined),
onPressed: () {},
),
const SizedBox(width: 25),
],
),
body: Container(
margin: const EdgeInsets.symmetric(horizontal: 32),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
const SizedBox(height: 40),
TextField(
decoration: const InputDecoration(
hintText: 'Title',
border: InputBorder.none,
),
maxLines: null,
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 40),
TextField(
decoration: const InputDecoration(
hintText: 'Note',
border: InputBorder.none,
),
style: Theme.of(context).textTheme.bodyLarge,
maxLines: null,
),
],
),
),
),
);
}
}
4 changes: 4 additions & 0 deletions lib/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ final themeData = ThemeData(
fontSize: 43,
fontWeight: FontWeight.w600,
),
bodyLarge: GoogleFonts.nunito(
fontSize: 23,
fontWeight: FontWeight.w400,
),
bodyMedium: GoogleFonts.nunito(
fontSize: 20,
fontWeight: FontWeight.w300,
Expand Down
20 changes: 20 additions & 0 deletions lib/widgets/go_back_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';

import 'square_icon_button.dart';

class GoBackButton extends StatelessWidget {
const GoBackButton({super.key});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 20),
child: SquareIconButton(
icon: SvgPicture.asset("assets/back.svg"),
onPressed: () => context.pop(),
),
);
}
}
21 changes: 21 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
go_router:
dependency: "direct main"
description:
name: go_router
sha256: c247a4f76071c3b97bb5ae8912968870d5565644801c5e09f3bc961b4d874895
url: "https://pub.dev"
source: hosted
version: "12.1.1"
google_fonts:
dependency: "direct main"
description:
Expand Down Expand Up @@ -139,6 +152,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
matcher:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies:
cupertino_icons: ^1.0.2
google_fonts: ^6.1.0
flutter_svg: ^2.0.9
go_router: ^12.1.1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 0ff8ef7

Please sign in to comment.