Browse Source

neon: remove nested scaffolds

pull/296/head
Nikolas Rimikis 2 years ago
parent
commit
1c3efedb3f
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 8
      packages/neon/neon/lib/src/pages/home.dart
  2. 5
      packages/neon/neon/lib/src/router.dart
  3. 1
      packages/neon/neon_files/lib/dialogs/choose_folder.dart
  4. 16
      packages/neon/neon_files/lib/pages/main.dart
  5. 21
      packages/neon/neon_files/lib/widgets/browser_view.dart
  6. 2
      packages/neon/neon_news/lib/neon_news.dart
  7. 4
      packages/neon/neon_news/lib/pages/folder.dart
  8. 37
      packages/neon/neon_news/lib/pages/main.dart
  9. 5
      packages/neon/neon_news/lib/widgets/articles_view.dart
  10. 29
      packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart
  11. 20
      packages/neon/neon_news/lib/widgets/feeds_view.dart
  12. 24
      packages/neon/neon_news/lib/widgets/folder_floating_action_button.dart
  13. 17
      packages/neon/neon_news/lib/widgets/folders_view.dart
  14. 1
      packages/neon/neon_notes/lib/neon_notes.dart
  15. 4
      packages/neon/neon_notes/lib/pages/category.dart
  16. 27
      packages/neon/neon_notes/lib/pages/main.dart
  17. 32
      packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart
  18. 23
      packages/neon/neon_notes/lib/widgets/notes_view.dart

8
packages/neon/neon/lib/src/pages/home.dart

@ -438,9 +438,7 @@ class _HomePageState extends State<HomePage> {
),
);
return Scaffold(
resizeToAvoidBottomInset: false,
body: Row(
return Row(
children: [
if (navigationMode == NavigationMode.drawerAlwaysVisible) ...[
drawer,
@ -568,8 +566,7 @@ class _HomePageState extends State<HomePage> {
Expanded(
child: Center(
child: Text(
AppLocalizations.of(context)
.errorNoCompatibleNextcloudAppsFound,
AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound,
textAlign: TextAlign.center,
),
),
@ -592,7 +589,6 @@ class _HomePageState extends State<HomePage> {
),
),
],
),
);
}
return Container();

5
packages/neon/neon/lib/src/router.dart

@ -30,14 +30,11 @@ class AppRouter extends RouterDelegate<Account> with ChangeNotifier, PopNavigato
] else ...[
MaterialPage(
name: 'home',
child: Scaffold(
resizeToAvoidBottomInset: false,
body: HomePage(
child: HomePage(
key: Key(currentConfiguration!.id),
account: currentConfiguration!,
),
),
),
],
],
);

1
packages/neon/neon_files/lib/dialogs/choose_folder.dart

@ -26,7 +26,6 @@ class FilesChooseFolderDialog extends StatelessWidget {
bloc: bloc,
filesBloc: filesBloc,
enableFileActions: false,
enableCreateActions: false,
onlyShowDirectories: true,
),
),

16
packages/neon/neon_files/lib/pages/main.dart

@ -23,7 +23,8 @@ class _FilesMainPageState extends State<FilesMainPage> {
}
@override
Widget build(final BuildContext context) => FilesBrowserView(
Widget build(final BuildContext context) => Scaffold(
body: FilesBrowserView(
bloc: widget.bloc.browser,
filesBloc: widget.bloc,
onPickFile: (final details) async {
@ -43,5 +44,18 @@ class _FilesMainPageState extends State<FilesMainPage> {
}
widget.bloc.openFile(details.path, details.etag!, details.mimeType);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
await showDialog(
context: context,
builder: (final context) => FilesChooseCreateDialog(
bloc: widget.bloc,
basePath: widget.bloc.browser.path.value,
),
);
},
child: const Icon(Icons.add),
),
);
}

21
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -6,7 +6,6 @@ class FilesBrowserView extends StatefulWidget {
required this.filesBloc,
this.onPickFile,
this.enableFileActions = true,
this.enableCreateActions = true,
this.onlyShowDirectories = false,
super.key,
// ignore: prefer_asserts_with_message
@ -16,7 +15,6 @@ class FilesBrowserView extends StatefulWidget {
final FilesBloc filesBloc;
final Function(FileDetails)? onPickFile;
final bool enableFileActions;
final bool enableCreateActions;
final bool onlyShowDirectories;
@override
@ -55,23 +53,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
}
return false;
},
child: Scaffold(
resizeToAvoidBottomInset: false,
floatingActionButton: widget.enableCreateActions
? FloatingActionButton(
onPressed: () async {
await showDialog(
context: context,
builder: (final context) => FilesChooseCreateDialog(
bloc: widget.filesBloc,
basePath: widget.bloc.path.value,
),
);
},
child: const Icon(Icons.add),
)
: null,
body: SortBoxBuilder<FilesSortProperty, WebDavFile>(
child: SortBoxBuilder<FilesSortProperty, WebDavFile>(
sortBox: filesSortBox,
sortPropertyOption: widget.bloc.options.filesSortPropertyOption,
sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption,
@ -203,7 +185,6 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
),
),
),
),
);
bool _pathMatchesFile(final List<String> path, final String name) => const ListEquality().equals(

2
packages/neon/neon_news/lib/neon_news.dart

@ -36,8 +36,10 @@ part 'sort/articles.dart';
part 'sort/feeds.dart';
part 'sort/folders.dart';
part 'widgets/articles_view.dart';
part 'widgets/feed_floating_action_button.dart';
part 'widgets/feed_icon.dart';
part 'widgets/feeds_view.dart';
part 'widgets/folder_floating_action_button.dart';
part 'widgets/folder_select.dart';
part 'widgets/folder_view.dart';
part 'widgets/folders_view.dart';

4
packages/neon/neon_news/lib/pages/folder.dart

@ -20,5 +20,9 @@ class NewsFolderPage extends StatelessWidget {
bloc: bloc,
folder: folder,
),
floatingActionButton: NewsFeedFloatingActionButton(
bloc: bloc,
folderID: folder.id,
),
);
}

37
packages/neon/neon_news/lib/pages/main.dart

@ -25,7 +25,27 @@ class _NewsMainPageState extends State<NewsMainPage> {
}
@override
Widget build(final BuildContext context) => Scaffold(
Widget build(final BuildContext context) {
final views = [
NewsArticlesView(
bloc: widget.bloc.mainArticlesBloc,
newsBloc: widget.bloc,
),
NewsFoldersView(
bloc: widget.bloc,
),
NewsFeedsView(
bloc: widget.bloc,
),
];
final floatingActionButtons = [
null,
NewsFolderFloatingActionButton(bloc: widget.bloc),
NewsFeedFloatingActionButton(bloc: widget.bloc),
];
return Scaffold(
resizeToAvoidBottomInset: false,
bottomNavigationBar: BottomNavigationBar(
currentIndex: _index,
@ -49,17 +69,8 @@ class _NewsMainPageState extends State<NewsMainPage> {
),
],
),
body: _index == 0
? NewsArticlesView(
bloc: widget.bloc.mainArticlesBloc,
newsBloc: widget.bloc,
)
: _index == 1
? NewsFoldersView(
bloc: widget.bloc,
)
: NewsFeedsView(
bloc: widget.bloc,
),
body: views[_index],
floatingActionButton: floatingActionButtons[_index],
);
}
}

5
packages/neon/neon_news/lib/widgets/articles_view.dart

@ -29,9 +29,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
stream: widget.newsBloc.feeds,
builder: (final context, final feeds) => ResultBuilder<List<NextcloudNewsArticle>>(
stream: widget.bloc.articles,
builder: (final context, final articles) => Scaffold(
resizeToAvoidBottomInset: false,
body: SortBoxBuilder<ArticlesSortProperty, NextcloudNewsArticle>(
builder: (final context, final articles) => SortBoxBuilder<ArticlesSortProperty, NextcloudNewsArticle>(
sortBox: articlesSortBox,
sortPropertyOption: widget.newsBloc.options.articlesSortPropertyOption,
sortBoxOrderOption: widget.newsBloc.options.articlesSortBoxOrderOption,
@ -98,7 +96,6 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
),
),
),
),
);
Widget _buildArticle(

29
packages/neon/neon_news/lib/widgets/feed_floating_action_button.dart

@ -0,0 +1,29 @@
part of '../neon_news.dart';
class NewsFeedFloatingActionButton extends StatelessWidget {
const NewsFeedFloatingActionButton({
required this.bloc,
this.folderID,
super.key,
});
final NewsBloc bloc;
final int? folderID;
@override
Widget build(final BuildContext context) => FloatingActionButton(
onPressed: () async {
final result = await showDialog<List>(
context: context,
builder: (final context) => NewsAddFeedDialog(
bloc: bloc,
folderID: folderID,
),
);
if (result != null) {
bloc.addFeed(result[0] as String, result[1] as int?);
}
},
child: const Icon(Icons.add),
);
}

20
packages/neon/neon_news/lib/widgets/feeds_view.dart

@ -15,24 +15,7 @@ class NewsFeedsView extends StatelessWidget {
stream: bloc.folders,
builder: (final context, final folders) => ResultBuilder<List<NextcloudNewsFeed>>(
stream: bloc.feeds,
builder: (final context, final feeds) => Scaffold(
resizeToAvoidBottomInset: false,
floatingActionButton: FloatingActionButton(
onPressed: () async {
final result = await showDialog<List>(
context: context,
builder: (final context) => NewsAddFeedDialog(
bloc: bloc,
folderID: folderID,
),
);
if (result != null) {
bloc.addFeed(result[0] as String, result[1] as int?);
}
},
child: const Icon(Icons.add),
),
body: SortBoxBuilder<FeedsSortProperty, NextcloudNewsFeed>(
builder: (final context, final feeds) => SortBoxBuilder<FeedsSortProperty, NextcloudNewsFeed>(
sortBox: feedsSortBox,
sortPropertyOption: bloc.options.feedsSortPropertyOption,
sortBoxOrderOption: bloc.options.feedsSortBoxOrderOption,
@ -54,7 +37,6 @@ class NewsFeedsView extends StatelessWidget {
),
),
),
),
);
Widget _buildFeed(

24
packages/neon/neon_news/lib/widgets/folder_floating_action_button.dart

@ -0,0 +1,24 @@
part of '../neon_news.dart';
class NewsFolderFloatingActionButton extends StatelessWidget {
const NewsFolderFloatingActionButton({
required this.bloc,
super.key,
});
final NewsBloc bloc;
@override
Widget build(final BuildContext context) => FloatingActionButton(
onPressed: () async {
final result = await showDialog<String>(
context: context,
builder: (final context) => const NewsCreateFolderDialog(),
);
if (result != null) {
bloc.createFolder(result);
}
},
child: const Icon(Icons.add),
);
}

17
packages/neon/neon_news/lib/widgets/folders_view.dart

@ -9,21 +9,7 @@ class NewsFoldersView extends StatelessWidget {
final NewsBloc bloc;
@override
Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false,
floatingActionButton: FloatingActionButton(
onPressed: () async {
final result = await showDialog<String>(
context: context,
builder: (final context) => const NewsCreateFolderDialog(),
);
if (result != null) {
bloc.createFolder(result);
}
},
child: const Icon(Icons.add),
),
body: ResultBuilder<List<NextcloudNewsFolder>>(
Widget build(final BuildContext context) => ResultBuilder<List<NextcloudNewsFolder>>(
stream: bloc.folders,
builder: (final context, final folders) => ResultBuilder<List<NextcloudNewsFeed>>(
stream: bloc.feeds,
@ -52,7 +38,6 @@ class NewsFoldersView extends StatelessWidget {
),
),
),
),
);
Widget _buildFolder(

1
packages/neon/neon_notes/lib/neon_notes.dart

@ -31,6 +31,7 @@ part 'utils/category_color.dart';
part 'utils/exception_handler.dart';
part 'widgets/categories_view.dart';
part 'widgets/category_select.dart';
part 'widgets/notes_floating_action_button.dart';
part 'widgets/notes_view.dart';
class NotesApp extends AppImplementation<NotesBloc, NotesAppSpecificOptions> {

4
packages/neon/neon_notes/lib/pages/category.dart

@ -20,5 +20,9 @@ class NotesCategoryPage extends StatelessWidget {
bloc: bloc,
category: category.name,
),
floatingActionButton: NotesFloatingActionButton(
bloc: bloc,
category: category.name,
),
);
}

27
packages/neon/neon_notes/lib/pages/main.dart

@ -25,7 +25,22 @@ class _NotesMainPageState extends State<NotesMainPage> {
}
@override
Widget build(final BuildContext context) => Scaffold(
Widget build(final BuildContext context) {
final views = [
NotesView(
bloc: widget.bloc,
),
NotesCategoriesView(
bloc: widget.bloc,
),
];
final floatingActionButtons = [
NotesFloatingActionButton(bloc: widget.bloc),
null,
];
return Scaffold(
resizeToAvoidBottomInset: false,
bottomNavigationBar: BottomNavigationBar(
currentIndex: _index,
@ -45,12 +60,8 @@ class _NotesMainPageState extends State<NotesMainPage> {
),
],
),
body: _index == 0
? NotesView(
bloc: widget.bloc,
)
: NotesCategoriesView(
bloc: widget.bloc,
),
body: views[_index],
floatingActionButton: floatingActionButtons[_index],
);
}
}

32
packages/neon/neon_notes/lib/widgets/notes_floating_action_button.dart

@ -0,0 +1,32 @@
part of '../neon_notes.dart';
class NotesFloatingActionButton extends StatelessWidget {
const NotesFloatingActionButton({
required this.bloc,
this.category,
super.key,
});
final NotesBloc bloc;
final String? category;
@override
Widget build(final BuildContext context) => FloatingActionButton(
onPressed: () async {
final result = await showDialog<List>(
context: context,
builder: (final context) => NotesCreateNoteDialog(
bloc: bloc,
category: category,
),
);
if (result != null) {
bloc.createNote(
title: result[0] as String,
category: result[1] as String? ?? '',
);
}
},
child: const Icon(Icons.add),
);
}

23
packages/neon/neon_notes/lib/widgets/notes_view.dart

@ -13,27 +13,7 @@ class NotesView extends StatelessWidget {
@override
Widget build(final BuildContext context) => ResultBuilder<List<NextcloudNotesNote>>(
stream: bloc.notes,
builder: (final context, final notes) => Scaffold(
resizeToAvoidBottomInset: false,
floatingActionButton: FloatingActionButton(
onPressed: () async {
final result = await showDialog<List>(
context: context,
builder: (final context) => NotesCreateNoteDialog(
bloc: bloc,
category: category,
),
);
if (result != null) {
bloc.createNote(
title: result[0] as String,
category: result[1] as String? ?? '',
);
}
},
child: const Icon(Icons.add),
),
body: SortBoxBuilder<NotesSortProperty, NextcloudNotesNote>(
builder: (final context, final notes) => SortBoxBuilder<NotesSortProperty, NextcloudNotesNote>(
sortBox: notesSortBox,
sortPropertyOption: bloc.options.notesSortPropertyOption,
sortBoxOrderOption: bloc.options.notesSortBoxOrderOption,
@ -61,7 +41,6 @@ class NotesView extends StatelessWidget {
),
),
),
),
);
Widget _buildNote(

Loading…
Cancel
Save