Static Nav Drawer in landscape
This commit is contained in:
234
lib/Journal.dart
234
lib/Journal.dart
@@ -44,6 +44,7 @@ class _JournalPageState extends State<JournalPage>{
|
||||
FocusNode _focus = FocusNode();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool landscape=((MediaQuery.of(context).size.width / MediaQuery.of(context).size.height) > 1);
|
||||
return Scaffold(
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
@@ -131,125 +132,134 @@ class _JournalPageState extends State<JournalPage>{
|
||||
],
|
||||
),
|
||||
),
|
||||
drawer: navDrawer(context, 8),
|
||||
body: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ScrollablePositionedList.builder(
|
||||
itemCount: User.journal.length,
|
||||
itemBuilder: (context, index) {
|
||||
int charCount = '\n'.allMatches(User.journal[index].description ?? '').length * 50;
|
||||
charCount +=(User.journal[index].description ?? '').length;
|
||||
int maxCharCount = 100;
|
||||
drawer: landscape ? null : navDrawer(context, 8),
|
||||
body: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
landscape?navDrawer(context, 8) : Container(),
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ScrollablePositionedList.builder(
|
||||
itemCount: User.journal.length,
|
||||
itemBuilder: (context, index) {
|
||||
int charCount = '\n'.allMatches(User.journal[index].description ?? '').length * 50;
|
||||
charCount +=(User.journal[index].description ?? '').length;
|
||||
int maxCharCount = 100;
|
||||
|
||||
bool matchesSearch = false;
|
||||
if(searching && searchController.text.isNotEmpty){
|
||||
if(User.journal[index].title != null && User.journal[index].title!.toLowerCase().contains(searchController.text.toLowerCase())){
|
||||
matchesSearch = true;
|
||||
}
|
||||
if((User.journal[index].description ?? '').toLowerCase().contains(searchController.text.toLowerCase())){
|
||||
matchesSearch=true;
|
||||
}
|
||||
}else{
|
||||
matchesSearch =true;
|
||||
}
|
||||
|
||||
return (matchesSearch) ? Container(
|
||||
child: InkWell(
|
||||
onTap: (){
|
||||
if(selecting){
|
||||
if(selectedIndexes.contains(index)){
|
||||
selectedIndexes.remove(index);
|
||||
}else{
|
||||
selectedIndexes.add(index);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}else{
|
||||
if(expandedIndex==index){
|
||||
expandedIndex=-1;
|
||||
//_controller..reverse(from: 0.5);
|
||||
}else {
|
||||
expandedIndex = index;
|
||||
// _controller..forward(from: 0);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
bool matchesSearch = false;
|
||||
if(searching && searchController.text.isNotEmpty){
|
||||
if(User.journal[index].title != null && User.journal[index].title!.toLowerCase().contains(searchController.text.toLowerCase())){
|
||||
matchesSearch = true;
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
selecting = !selecting;
|
||||
if(!selectedIndexes.contains(index)){selectedIndexes.add(index);}
|
||||
setState(() {});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
if (selecting)
|
||||
Checkbox(
|
||||
value: selectedIndexes.contains(index),
|
||||
onChanged: (newVal) {
|
||||
if(selectedIndexes.contains(index)){
|
||||
selectedIndexes.remove(index);
|
||||
}else{
|
||||
selectedIndexes.add(index);
|
||||
}
|
||||
setState(() {
|
||||
if((User.journal[index].description ?? '').toLowerCase().contains(searchController.text.toLowerCase())){
|
||||
matchesSearch=true;
|
||||
}
|
||||
}else{
|
||||
matchesSearch =true;
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: AnimatedContainer(
|
||||
duration: Duration(seconds: 1),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
(User.journal[index].title!=null && User.journal[index].title!.isNotEmpty) ?
|
||||
Text(User.journal[index].title!, style: TextStyle(fontSize: 18)) :
|
||||
Text(DateFormat('MMMM-dd').format( User.journal[index].day), style: TextStyle(fontSize: 18)),
|
||||
Container(padding:EdgeInsets.symmetric(horizontal: 10,vertical: 2),decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),color: Colors.black26),child: Text(DateFormat('yyyy-MM-dd').format(User.journal[index].day)))
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5,),
|
||||
if (User.journal[index].description != null && User.journal[index].description!.isNotEmpty)
|
||||
(charCount > maxCharCount && expandedIndex != index) ?
|
||||
Text(User.journal[index].description!.substring(0,maxCharCount.clamp(0,User.journal[index].description!.length)) + '...') :
|
||||
Text(User.journal[index].description!),
|
||||
return (matchesSearch) ? Container(
|
||||
child: InkWell(
|
||||
onTap: (){
|
||||
if(selecting){
|
||||
if(selectedIndexes.contains(index)){
|
||||
selectedIndexes.remove(index);
|
||||
}else{
|
||||
selectedIndexes.add(index);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
if(charCount>maxCharCount) Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(),
|
||||
(index == expandedIndex)? Icon(Icons.keyboard_arrow_up) : Icon(Icons.keyboard_arrow_down)
|
||||
});
|
||||
}else{
|
||||
if(expandedIndex==index){
|
||||
expandedIndex=-1;
|
||||
//_controller..reverse(from: 0.5);
|
||||
}else {
|
||||
expandedIndex = index;
|
||||
// _controller..forward(from: 0);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if(selecting)InkWell(onTap:(){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => NewJournal(date: User.journal[index].day, title: User.journal[index].title, text: User.journal[index].description,))).then((val) {
|
||||
});
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
selecting = !selecting;
|
||||
if(!selectedIndexes.contains(index)){selectedIndexes.add(index);}
|
||||
setState(() {});
|
||||
});
|
||||
selecting=false;
|
||||
setState(() {
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
if (selecting)
|
||||
Checkbox(
|
||||
value: selectedIndexes.contains(index),
|
||||
onChanged: (newVal) {
|
||||
if(selectedIndexes.contains(index)){
|
||||
selectedIndexes.remove(index);
|
||||
}else{
|
||||
selectedIndexes.add(index);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
},child: Container(margin:EdgeInsets.all(8),child: FaIcon(FontAwesomeIcons.edit)))
|
||||
],
|
||||
),
|
||||
)) : Container();
|
||||
}),
|
||||
});
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: AnimatedContainer(
|
||||
duration: Duration(seconds: 1),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
(User.journal[index].title!=null && User.journal[index].title!.isNotEmpty) ?
|
||||
Text(User.journal[index].title!, style: TextStyle(fontSize: 18)) :
|
||||
Text(DateFormat('MMMM-dd').format( User.journal[index].day), style: TextStyle(fontSize: 18)),
|
||||
Container(padding:EdgeInsets.symmetric(horizontal: 10,vertical: 2),decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),color: Colors.black26),child: Text(DateFormat('yyyy-MM-dd').format(User.journal[index].day)))
|
||||
],
|
||||
),
|
||||
SizedBox(height: 5,),
|
||||
if (User.journal[index].description != null && User.journal[index].description!.isNotEmpty)
|
||||
(charCount > maxCharCount && expandedIndex != index) ?
|
||||
Text(User.journal[index].description!.substring(0,maxCharCount.clamp(0,User.journal[index].description!.length)) + '...') :
|
||||
Text(User.journal[index].description!),
|
||||
|
||||
if(charCount>maxCharCount) Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(),
|
||||
(index == expandedIndex)? Icon(Icons.keyboard_arrow_up) : Icon(Icons.keyboard_arrow_down)
|
||||
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if(selecting)InkWell(onTap:(){
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => NewJournal(date: User.journal[index].day, title: User.journal[index].title, text: User.journal[index].description,))).then((val) {
|
||||
setState(() {});
|
||||
});
|
||||
selecting=false;
|
||||
setState(() {
|
||||
|
||||
});
|
||||
},child: Container(margin:EdgeInsets.all(8),child: FaIcon(FontAwesomeIcons.edit)))
|
||||
],
|
||||
),
|
||||
)) : Container();
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user