mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-25 00:00:26 +08:00
FolderViews: Hide the AppBar when scrolling
This breaks a number of other things, but this commit was becoming messy.
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder.dart';
|
||||
import 'package:gitjournal/folder_views/empty_text_sliver.dart';
|
||||
import 'package:gitjournal/folder_views/note_tile.dart';
|
||||
|
||||
class CardView extends StatelessWidget {
|
||||
@ -30,17 +31,7 @@ class CardView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (folder.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
emptyText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 28.0,
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.grey[350],
|
||||
),
|
||||
),
|
||||
);
|
||||
return EmptyTextSliver(emptyText: emptyText);
|
||||
}
|
||||
|
||||
StaggeredTile stagTile;
|
||||
@ -50,7 +41,7 @@ class CardView extends StatelessWidget {
|
||||
stagTile = const StaggeredTile.fit(1);
|
||||
}
|
||||
|
||||
var gridView = StaggeredGridView.extentBuilder(
|
||||
var gridView = SliverStaggeredGrid.extentBuilder(
|
||||
itemCount: folder.notes.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var note = folder.notes[index];
|
||||
@ -66,9 +57,11 @@ class CardView extends StatelessWidget {
|
||||
staggeredTileBuilder: (int i) => stagTile,
|
||||
mainAxisSpacing: 8.0,
|
||||
crossAxisSpacing: 8.0,
|
||||
padding: const EdgeInsets.fromLTRB(8.0, 16.0, 8.0, 16.0),
|
||||
);
|
||||
|
||||
return gridView;
|
||||
return SliverPadding(
|
||||
sliver: gridView,
|
||||
padding: const EdgeInsets.fromLTRB(8.0, 12.0, 8.0, 12.0 + 48.0),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
30
lib/folder_views/empty_text_sliver.dart
Normal file
30
lib/folder_views/empty_text_sliver.dart
Normal file
@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// FIXME: Why are you scrollable!!
|
||||
class EmptyTextSliver extends StatelessWidget {
|
||||
const EmptyTextSliver({
|
||||
Key? key,
|
||||
required this.emptyText,
|
||||
}) : super(key: key);
|
||||
|
||||
final String emptyText;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverFillRemaining(
|
||||
child: Center(
|
||||
child: Text(
|
||||
emptyText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 28.0,
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.grey[350],
|
||||
),
|
||||
),
|
||||
),
|
||||
hasScrollBody: false,
|
||||
fillOverscroll: false,
|
||||
);
|
||||
}
|
||||
}
|
@ -94,40 +94,38 @@ class _FolderViewState extends State<FolderView> {
|
||||
title = NumberFormat.compact().format(1);
|
||||
}
|
||||
|
||||
Widget folderView = Builder(
|
||||
builder: (BuildContext context) {
|
||||
return buildFolderView(
|
||||
viewType: _viewType,
|
||||
folder: sortedNotesFolder,
|
||||
emptyText: tr('screens.folder_view.empty'),
|
||||
header: _headerType,
|
||||
showSummary: _showSummary,
|
||||
noteTapped: (Note note) {
|
||||
if (!inSelectionMode) {
|
||||
openNoteEditor(context, note, widget.notesFolder);
|
||||
} else {
|
||||
_resetSelection();
|
||||
}
|
||||
},
|
||||
noteLongPressed: (Note note) {
|
||||
setState(() {
|
||||
inSelectionMode = true;
|
||||
selectedNote = note;
|
||||
});
|
||||
},
|
||||
isNoteSelected: (n) => n == selectedNote,
|
||||
searchTerm: "",
|
||||
);
|
||||
// vHanda: Fixme the openNoteEditor will fail! Wrong context!
|
||||
var folderView = buildFolderView(
|
||||
viewType: _viewType,
|
||||
folder: sortedNotesFolder,
|
||||
emptyText: tr('screens.folder_view.empty'),
|
||||
header: _headerType,
|
||||
showSummary: _showSummary,
|
||||
noteTapped: (Note note) {
|
||||
if (!inSelectionMode) {
|
||||
openNoteEditor(context, note, widget.notesFolder);
|
||||
} else {
|
||||
_resetSelection();
|
||||
}
|
||||
},
|
||||
noteLongPressed: (Note note) {
|
||||
setState(() {
|
||||
inSelectionMode = true;
|
||||
selectedNote = note;
|
||||
});
|
||||
},
|
||||
isNoteSelected: (n) => n == selectedNote,
|
||||
searchTerm: "",
|
||||
);
|
||||
// assert(folderView is SliverWithKeepAliveWidget);
|
||||
|
||||
var settings = Provider.of<Settings>(context);
|
||||
final showButtomMenuBar = settings.bottomMenuBar;
|
||||
|
||||
// So the FAB doesn't hide parts of the last entry
|
||||
if (!showButtomMenuBar) {
|
||||
folderView = Padding(
|
||||
child: folderView,
|
||||
folderView = SliverPadding(
|
||||
sliver: folderView,
|
||||
padding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 48.0),
|
||||
);
|
||||
}
|
||||
@ -138,14 +136,22 @@ class _FolderViewState extends State<FolderView> {
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
leading: inSelectionMode ? backButton : GJAppBarMenuButton(),
|
||||
actions: inSelectionMode
|
||||
? _buildInSelectionNoteActions()
|
||||
: _buildNoteActions(),
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
title: Text(title),
|
||||
leading: inSelectionMode ? backButton : GJAppBarMenuButton(),
|
||||
actions: inSelectionMode
|
||||
? _buildInSelectionNoteActions()
|
||||
: _buildNoteActions(),
|
||||
floating: true,
|
||||
forceElevated: true,
|
||||
),
|
||||
folderView,
|
||||
],
|
||||
),
|
||||
body: Center(
|
||||
/*
|
||||
Center(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
var child = Scrollbar(child: folderView);
|
||||
@ -159,6 +165,7 @@ class _FolderViewState extends State<FolderView> {
|
||||
},
|
||||
),
|
||||
),
|
||||
*/
|
||||
extendBody: true,
|
||||
drawer: AppDrawer(),
|
||||
floatingActionButton: createButton,
|
||||
|
@ -9,6 +9,7 @@ import 'package:gitjournal/repository.dart';
|
||||
import 'package:gitjournal/settings/settings.dart';
|
||||
import 'package:gitjournal/utils/utils.dart';
|
||||
import 'package:gitjournal/widgets/icon_dismissable.dart';
|
||||
import 'empty_text_sliver.dart';
|
||||
|
||||
typedef Widget NoteTileBuilder(BuildContext context, Note note);
|
||||
|
||||
@ -97,25 +98,14 @@ class _FolderListViewState extends State<FolderListView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.folder.notes.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
widget.emptyText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 28.0,
|
||||
fontWeight: FontWeight.w300,
|
||||
color: Colors.grey[350],
|
||||
),
|
||||
),
|
||||
);
|
||||
if (widget.folder.isEmpty) {
|
||||
return EmptyTextSliver(emptyText: widget.emptyText);
|
||||
}
|
||||
|
||||
return AnimatedList(
|
||||
return SliverAnimatedList(
|
||||
key: _listKey,
|
||||
itemBuilder: _buildItem,
|
||||
initialItemCount: widget.folder.notes.length,
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 48),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ class NoteTile extends StatelessWidget {
|
||||
|
||||
static const _maxLines = 12;
|
||||
|
||||
// FIXME: vHanda: This doesn't need to be computed again and again!
|
||||
String _displayText() {
|
||||
var foundSearchTerm = searchTerm.isEmpty ? true : false;
|
||||
var buffer = <String>[];
|
||||
|
Reference in New Issue
Block a user