Polished
This commit is contained in:
@@ -15,11 +15,13 @@ class JournalPage extends StatefulWidget {
|
||||
State<JournalPage> createState() => _JournalPageState();
|
||||
}
|
||||
|
||||
class _JournalPageState extends State<JournalPage> {
|
||||
class _JournalPageState extends State<JournalPage>{
|
||||
|
||||
bool selecting = false;
|
||||
List<int> selectedIndexes = [];
|
||||
int expandedIndex = -1;
|
||||
var refreshStream;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
@@ -28,6 +30,7 @@ class _JournalPageState extends State<JournalPage> {
|
||||
refreshStream = User.refreshStream.stream.listen((event) {if(!event){setState(() {
|
||||
|
||||
});}});
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -88,9 +91,10 @@ class _JournalPageState extends State<JournalPage> {
|
||||
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;
|
||||
return Container(
|
||||
|
||||
//duration: Duration(milliseconds: 500),
|
||||
child: InkWell(
|
||||
onTap: (){
|
||||
if(selecting){
|
||||
@@ -101,6 +105,17 @@ class _JournalPageState extends State<JournalPage> {
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}else{
|
||||
if(expandedIndex==index){
|
||||
expandedIndex=-1;
|
||||
//_controller..reverse(from: 0.5);
|
||||
}else {
|
||||
expandedIndex = index;
|
||||
// _controller..forward(from: 0);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -129,19 +144,36 @@ class _JournalPageState extends State<JournalPage> {
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(User.journal[index].title ?? '', style: TextStyle(fontSize: 18)),
|
||||
Text(DateFormat('yyyy-MM-dd').format(User.journal[index].day))
|
||||
],
|
||||
),
|
||||
if (User.journal[index].description != null && User.journal[index].description!.isNotEmpty)
|
||||
Text(User.journal[index].description!)
|
||||
],
|
||||
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) + '...') :
|
||||
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)
|
||||
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user