mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 03:18:43 +08:00
Allow the notes to be refreshed by pulling from the top
This commit is contained in:
@ -17,12 +17,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
child: new Icon(Icons.add),
|
child: new Icon(Icons.add),
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Scaffold(
|
var journalList = JournalList(
|
||||||
appBar: new AppBar(
|
|
||||||
title: new Text('GitJournal'),
|
|
||||||
),
|
|
||||||
floatingActionButton: createButton,
|
|
||||||
body: new JournalList(
|
|
||||||
notes: appState.notes,
|
notes: appState.notes,
|
||||||
noteSelectedFunction: (noteIndex) {
|
noteSelectedFunction: (noteIndex) {
|
||||||
var route = new MaterialPageRoute(
|
var route = new MaterialPageRoute(
|
||||||
@ -33,6 +28,18 @@ class HomeScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
Navigator.of(context).push(route);
|
Navigator.of(context).push(route);
|
||||||
},
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Scaffold(
|
||||||
|
appBar: new AppBar(
|
||||||
|
title: new Text('GitJournal'),
|
||||||
|
),
|
||||||
|
floatingActionButton: createButton,
|
||||||
|
body: Center(
|
||||||
|
child: RefreshIndicator(
|
||||||
|
child: journalList,
|
||||||
|
onRefresh: container.syncNotes,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
drawer: new AppDrawer(),
|
drawer: new AppDrawer(),
|
||||||
);
|
);
|
||||||
|
@ -96,6 +96,33 @@ class StateContainerState extends State<StateContainer> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future syncNotes() async {
|
||||||
|
try {
|
||||||
|
await noteRepo.sync();
|
||||||
|
} catch (err, stack) {
|
||||||
|
print("Notes Repo Sync Error: " + err.toString());
|
||||||
|
print(stack.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
appState.isLoadingFromDisk = true;
|
||||||
|
var loadedNotes = await noteRepo.listNotes();
|
||||||
|
setState(() {
|
||||||
|
appState.isLoadingFromDisk = false;
|
||||||
|
appState.notes = loadedNotes;
|
||||||
|
});
|
||||||
|
} catch (err, stack) {
|
||||||
|
setState(() {
|
||||||
|
print("Load Notes From Disk Error: " + err.toString());
|
||||||
|
print(stack.toString());
|
||||||
|
appState.isLoadingFromDisk = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void _syncNotes() {
|
void _syncNotes() {
|
||||||
print("Starting to syncNOtes");
|
print("Starting to syncNOtes");
|
||||||
this.noteRepo.sync().then((loaded) {
|
this.noteRepo.sync().then((loaded) {
|
||||||
|
Reference in New Issue
Block a user