Browse Source

Merge pull request #296 from Leptopoda/fix/nested_scaffold

remove nested scaffolds
pull/302/head
Kate 2 years ago committed by GitHub
parent
commit
03d992831f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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( return Row(
resizeToAvoidBottomInset: false,
body: Row(
children: [ children: [
if (navigationMode == NavigationMode.drawerAlwaysVisible) ...[ if (navigationMode == NavigationMode.drawerAlwaysVisible) ...[
drawer, drawer,
@ -568,8 +566,7 @@ class _HomePageState extends State<HomePage> {
Expanded( Expanded(
child: Center( child: Center(
child: Text( child: Text(
AppLocalizations.of(context) AppLocalizations.of(context).errorNoCompatibleNextcloudAppsFound,
.errorNoCompatibleNextcloudAppsFound,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
@ -592,7 +589,6 @@ class _HomePageState extends State<HomePage> {
), ),
), ),
], ],
),
); );
} }
return Container(); return Container();

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

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

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

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

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

@ -23,7 +23,8 @@ class _FilesMainPageState extends State<FilesMainPage> {
} }
@override @override
Widget build(final BuildContext context) => FilesBrowserView( Widget build(final BuildContext context) => Scaffold(
body: FilesBrowserView(
bloc: widget.bloc.browser, bloc: widget.bloc.browser,
filesBloc: widget.bloc, filesBloc: widget.bloc,
onPickFile: (final details) async { onPickFile: (final details) async {
@ -43,5 +44,18 @@ class _FilesMainPageState extends State<FilesMainPage> {
} }
widget.bloc.openFile(details.path, details.etag!, details.mimeType); 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, required this.filesBloc,
this.onPickFile, this.onPickFile,
this.enableFileActions = true, this.enableFileActions = true,
this.enableCreateActions = true,
this.onlyShowDirectories = false, this.onlyShowDirectories = false,
super.key, super.key,
// ignore: prefer_asserts_with_message // ignore: prefer_asserts_with_message
@ -16,7 +15,6 @@ class FilesBrowserView extends StatefulWidget {
final FilesBloc filesBloc; final FilesBloc filesBloc;
final Function(FileDetails)? onPickFile; final Function(FileDetails)? onPickFile;
final bool enableFileActions; final bool enableFileActions;
final bool enableCreateActions;
final bool onlyShowDirectories; final bool onlyShowDirectories;
@override @override
@ -55,23 +53,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
} }
return false; return false;
}, },
child: Scaffold( child: SortBoxBuilder<FilesSortProperty, WebDavFile>(
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>(
sortBox: filesSortBox, sortBox: filesSortBox,
sortPropertyOption: widget.bloc.options.filesSortPropertyOption, sortPropertyOption: widget.bloc.options.filesSortPropertyOption,
sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption, 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( 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/feeds.dart';
part 'sort/folders.dart'; part 'sort/folders.dart';
part 'widgets/articles_view.dart'; part 'widgets/articles_view.dart';
part 'widgets/feed_floating_action_button.dart';
part 'widgets/feed_icon.dart'; part 'widgets/feed_icon.dart';
part 'widgets/feeds_view.dart'; part 'widgets/feeds_view.dart';
part 'widgets/folder_floating_action_button.dart';
part 'widgets/folder_select.dart'; part 'widgets/folder_select.dart';
part 'widgets/folder_view.dart'; part 'widgets/folder_view.dart';
part 'widgets/folders_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, bloc: bloc,
folder: folder, 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 @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, resizeToAvoidBottomInset: false,
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(
currentIndex: _index, currentIndex: _index,
@ -49,17 +69,8 @@ class _NewsMainPageState extends State<NewsMainPage> {
), ),
], ],
), ),
body: _index == 0 body: views[_index],
? NewsArticlesView( floatingActionButton: floatingActionButtons[_index],
bloc: widget.bloc.mainArticlesBloc,
newsBloc: widget.bloc,
)
: _index == 1
? NewsFoldersView(
bloc: widget.bloc,
)
: NewsFeedsView(
bloc: widget.bloc,
),
); );
} }
}

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

@ -29,9 +29,7 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
stream: widget.newsBloc.feeds, stream: widget.newsBloc.feeds,
builder: (final context, final feeds) => ResultBuilder<List<NextcloudNewsArticle>>( builder: (final context, final feeds) => ResultBuilder<List<NextcloudNewsArticle>>(
stream: widget.bloc.articles, stream: widget.bloc.articles,
builder: (final context, final articles) => Scaffold( builder: (final context, final articles) => SortBoxBuilder<ArticlesSortProperty, NextcloudNewsArticle>(
resizeToAvoidBottomInset: false,
body: SortBoxBuilder<ArticlesSortProperty, NextcloudNewsArticle>(
sortBox: articlesSortBox, sortBox: articlesSortBox,
sortPropertyOption: widget.newsBloc.options.articlesSortPropertyOption, sortPropertyOption: widget.newsBloc.options.articlesSortPropertyOption,
sortBoxOrderOption: widget.newsBloc.options.articlesSortBoxOrderOption, sortBoxOrderOption: widget.newsBloc.options.articlesSortBoxOrderOption,
@ -98,7 +96,6 @@ class _NewsArticlesViewState extends State<NewsArticlesView> {
), ),
), ),
), ),
),
); );
Widget _buildArticle( 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, stream: bloc.folders,
builder: (final context, final folders) => ResultBuilder<List<NextcloudNewsFeed>>( builder: (final context, final folders) => ResultBuilder<List<NextcloudNewsFeed>>(
stream: bloc.feeds, stream: bloc.feeds,
builder: (final context, final feeds) => Scaffold( builder: (final context, final feeds) => SortBoxBuilder<FeedsSortProperty, NextcloudNewsFeed>(
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>(
sortBox: feedsSortBox, sortBox: feedsSortBox,
sortPropertyOption: bloc.options.feedsSortPropertyOption, sortPropertyOption: bloc.options.feedsSortPropertyOption,
sortBoxOrderOption: bloc.options.feedsSortBoxOrderOption, sortBoxOrderOption: bloc.options.feedsSortBoxOrderOption,
@ -54,7 +37,6 @@ class NewsFeedsView extends StatelessWidget {
), ),
), ),
), ),
),
); );
Widget _buildFeed( 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; final NewsBloc bloc;
@override @override
Widget build(final BuildContext context) => Scaffold( Widget build(final BuildContext context) => ResultBuilder<List<NextcloudNewsFolder>>(
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>>(
stream: bloc.folders, stream: bloc.folders,
builder: (final context, final folders) => ResultBuilder<List<NextcloudNewsFeed>>( builder: (final context, final folders) => ResultBuilder<List<NextcloudNewsFeed>>(
stream: bloc.feeds, stream: bloc.feeds,
@ -52,7 +38,6 @@ class NewsFoldersView extends StatelessWidget {
), ),
), ),
), ),
),
); );
Widget _buildFolder( 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 'utils/exception_handler.dart';
part 'widgets/categories_view.dart'; part 'widgets/categories_view.dart';
part 'widgets/category_select.dart'; part 'widgets/category_select.dart';
part 'widgets/notes_floating_action_button.dart';
part 'widgets/notes_view.dart'; part 'widgets/notes_view.dart';
class NotesApp extends AppImplementation<NotesBloc, NotesAppSpecificOptions> { 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, bloc: bloc,
category: category.name, 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 @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, resizeToAvoidBottomInset: false,
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(
currentIndex: _index, currentIndex: _index,
@ -45,12 +60,8 @@ class _NotesMainPageState extends State<NotesMainPage> {
), ),
], ],
), ),
body: _index == 0 body: views[_index],
? NotesView( floatingActionButton: floatingActionButtons[_index],
bloc: widget.bloc,
)
: NotesCategoriesView(
bloc: widget.bloc,
),
); );
} }
}

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 @override
Widget build(final BuildContext context) => ResultBuilder<List<NextcloudNotesNote>>( Widget build(final BuildContext context) => ResultBuilder<List<NextcloudNotesNote>>(
stream: bloc.notes, stream: bloc.notes,
builder: (final context, final notes) => Scaffold( builder: (final context, final notes) => SortBoxBuilder<NotesSortProperty, NextcloudNotesNote>(
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>(
sortBox: notesSortBox, sortBox: notesSortBox,
sortPropertyOption: bloc.options.notesSortPropertyOption, sortPropertyOption: bloc.options.notesSortPropertyOption,
sortBoxOrderOption: bloc.options.notesSortBoxOrderOption, sortBoxOrderOption: bloc.options.notesSortBoxOrderOption,
@ -61,7 +41,6 @@ class NotesView extends StatelessWidget {
), ),
), ),
), ),
),
); );
Widget _buildNote( Widget _buildNote(

Loading…
Cancel
Save