Skip to content

Commit

Permalink
improved design
Browse files Browse the repository at this point in the history
  • Loading branch information
judemont committed Apr 23, 2024
1 parent ae833d6 commit caa405c
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 96 deletions.
29 changes: 17 additions & 12 deletions lib/screens/pages_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,36 @@ import 'package:reciper/widgets/bottom_nav_bar.dart';
class PagesLayout extends StatefulWidget {
final Widget? child;
final bool displayBottomNavBar;
final int currentSection;

const PagesLayout({super.key, this.child, this.displayBottomNavBar = true});
const PagesLayout(
{super.key,
this.child,
this.displayBottomNavBar = true,
this.currentSection = 0});

@override
State<PagesLayout> createState() => _PagesLayoutState();
}

class _PagesLayoutState extends State<PagesLayout> {
int? currentPageIndex;

@override
Widget build(BuildContext context) {
return Scaffold(
body: currentPageIndex == null
? widget.child
: [
const HomePage(),
const RecipeEditorPage(),
const Settings()
][currentPageIndex!],
body: widget.child,
bottomNavigationBar: widget.displayBottomNavBar
? BottomNavBar(
selectedIndex: currentPageIndex ?? 0,
selectedIndex: widget.currentSection,
onDestinationSelected: (index) => setState(() {
currentPageIndex = index;
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => PagesLayout(
currentSection: index,
child: [
const HomePage(),
const RecipeEditorPage(),
const Settings(),
][index]),
));
}),
)
: null,
Expand Down
1 change: 1 addition & 0 deletions lib/screens/recipe_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class _RecipeViewPageState extends State<RecipeViewPage> {
Navigator.of(context)
.push(MaterialPageRoute(
builder: (context) => PagesLayout(
currentSection: 1,
displayBottomNavBar: false,
child: RecipeEditorPage(
initialRecipe: widget.recipe,
Expand Down
126 changes: 42 additions & 84 deletions lib/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,8 @@ import 'package:flutter/material.dart';
import 'package:reciper/utilities/utils.dart';
import 'package:url_launcher/url_launcher.dart';

class Settings extends StatefulWidget {
const Settings({super.key});

@override
State<Settings> createState() => _SettingsState();
}

class _SettingsState extends State<Settings> {
int _displayedTabIndex = 0;

void setDisplayedTab(int index) {
setState(() {
if (_displayedTabIndex == index) {
_displayedTabIndex = 0;
} else {
_displayedTabIndex = index;
}
});
}
class Settings extends StatelessWidget {
const Settings({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand All @@ -31,80 +14,55 @@ class _SettingsState extends State<Settings> {
centerTitle: true,
),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ListTile(
selected: _displayedTabIndex == 1,
onTap: () {
setDisplayedTab(1);
},
title: const Text("Import"),
),
Visibility(
visible: _displayedTabIndex == 1,
child: Container(
margin: const EdgeInsets.only(left: 20),
child: Column(
children: [
ListTile(
title: const Text("Import recipes"),
onTap: () {
Utils.import();
Navigator.pop(context);
}),
],
),
),
const Text(
"Import",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
ListTile(
selected: _displayedTabIndex == 2,
onTap: () {
setDisplayedTab(2);
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Utils.import();
Navigator.pop(context);
},
title: const Text("Export"),
child: const Text("Import recipes"),
),
Visibility(
visible: _displayedTabIndex == 2,
child: Container(
margin: const EdgeInsets.only(left: 20),
child: Column(
children: [
ListTile(
title: const Text("Export recipes"),
onTap: () => Utils.export(),
),
],
),
),
const SizedBox(height: 20),
const Text(
"Export",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
ListTile(
selected: _displayedTabIndex == 3,
onTap: () {
setDisplayedTab(3);
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
Utils.export();
},
title: const Text("About"),
child: const Text("Export recipes"),
),
const SizedBox(height: 20),
const Text(
"About",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
Visibility(
visible: _displayedTabIndex == 3,
child: Container(
margin: const EdgeInsets.only(left: 20),
child: Column(
children: [
const ListTile(
title: Text(
"Reciper has been developed with ❤️ by Judemont and Rdemont"),
),
ListTile(
title: const Text(
"Source code (GitHub)",
style: TextStyle(color: Colors.blue),
),
onTap: () => launchUrl(
Uri.parse('https://github.com/judemont/reciper')),
)
],
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Reciper has been developed with ❤️ by Judemont",
style: TextStyle(fontSize: 16),
),
const SizedBox(height: 20),
ElevatedButton.icon(
onPressed: () => launchUrl(
Uri.parse('https://github.com/judemont/reciper'),
),
icon: const Icon(Icons.link),
label: const Text("Source code (GitHub)"),
),
),
],
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/extract_recipe_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class _ExtractRecipeDialogState extends State<ExtractRecipeDialog> {
context,
MaterialPageRoute(
builder: (context) => PagesLayout(
currentSection: 1,
child: RecipeEditorPage(
initialRecipe: Recipe(
title: recipeData.name ?? "",
Expand Down

0 comments on commit caa405c

Please sign in to comment.