Polished
This commit is contained in:
@@ -257,7 +257,7 @@ class _ActivitiesState extends State<Activities> {
|
||||
//_tasks.add(DateSeperator(thisDate, prodActs, unProdActs));
|
||||
// _tasks.putIfAbsent(DateSeperator(thisDate, prodActs, unProdActs), () => [List.generate(0, (i) => List(2));]);
|
||||
_tasks.putIfAbsent(thisDate, () => ActivityListDateGroup(DateSeperator(thisDate, prodActs, unProdActs), []));
|
||||
print('adding');
|
||||
// print('adding');
|
||||
lastDate = thisDate;
|
||||
}
|
||||
String name = element.taskType.name;
|
||||
@@ -393,7 +393,7 @@ class _ActivitiesState extends State<Activities> {
|
||||
if(prodPercentage < 35)Text(Main.MinutesToTimeString(prodActs),),
|
||||
Container(
|
||||
child: Align(
|
||||
child: (prodPercentage >= 35) ?Text(Main.MinutesToTimeString(prodActs),) : Container(),
|
||||
child: (prodPercentage >= 35) ?FittedBox(child: Text(Main.MinutesToTimeString(prodActs),)) : Container(),
|
||||
alignment: Alignment.center,
|
||||
),
|
||||
width: (prodPercentage) * 1,
|
||||
|
||||
@@ -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)
|
||||
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
import 'User.dart' as User;
|
||||
import 'Data.dart';
|
||||
import 'Dialogs.dart';
|
||||
|
||||
class NewJournal extends StatefulWidget {
|
||||
NewJournal({Key? key, this.title, this.text, this.date}) : super(key: key);
|
||||
@@ -18,11 +19,31 @@ class NewJournal extends StatefulWidget {
|
||||
|
||||
class _NewJournalState extends State<NewJournal> {
|
||||
bool editing =false;
|
||||
|
||||
DateTime date= DateTime.now();
|
||||
DateFormat dFormat = DateFormat('yyyy-MM-dd');
|
||||
_NewJournalState({String? title, String? text, DateTime? m_date}){
|
||||
if(m_date!= null){
|
||||
editing = true;
|
||||
date=m_date;
|
||||
oldDate =m_date;
|
||||
}else{
|
||||
bool foundEmptyDate = false;
|
||||
while(!foundEmptyDate) {
|
||||
bool exist = false;
|
||||
for (var element in User.journal) {
|
||||
if (dFormat.format(element.day) == dFormat.format(date)) {
|
||||
//Wat!
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
foundEmptyDate=true;
|
||||
}else{
|
||||
date = date.subtract(Duration(days: 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
titleController.text = title??'';
|
||||
@@ -33,7 +54,6 @@ class _NewJournalState extends State<NewJournal> {
|
||||
TextEditingController descriptionEditingController = TextEditingController();
|
||||
bool productive = true;
|
||||
Color pickerColor = Colors.blue;
|
||||
DateTime date= DateTime.now();
|
||||
DateTime oldDate = DateTime.now();
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -57,8 +77,25 @@ class _NewJournalState extends State<NewJournal> {
|
||||
theme: DatePickerTheme(), onChanged: (date) {
|
||||
// print('change $date');
|
||||
}, onConfirm: (newDate){
|
||||
date = newDate;
|
||||
}, currentTime: DateTime.now(), locale: LocaleType.en);
|
||||
bool exist =false;
|
||||
for (var element in User.journal) {
|
||||
if(dFormat.format(element.day) == dFormat.format(newDate)){
|
||||
//Wat!
|
||||
exist=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(exist){
|
||||
Dialogs.showAlertDialog(context, 'Cant duplicate entries!', 'Journal entry was found on this date, Please edit that instead of adding new entry.');
|
||||
}else {
|
||||
date = newDate;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}, currentTime: date, locale: LocaleType.en);
|
||||
},
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
@@ -70,7 +107,7 @@ class _NewJournalState extends State<NewJournal> {
|
||||
Text('Date : '),
|
||||
SizedBox(width: 30,),
|
||||
Text(
|
||||
DateFormat('yyyy-MM-dd').format(date),
|
||||
dFormat.format(date),
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
SizedBox(width: 30,),
|
||||
@@ -146,6 +183,19 @@ class _NewJournalState extends State<NewJournal> {
|
||||
if(editing){
|
||||
await User.UserOperations.editJournal(oldDate,date,title,text);
|
||||
}else{
|
||||
bool exist =false;
|
||||
for (var element in User.journal) {
|
||||
if(element.day== date){
|
||||
//Wat!
|
||||
exist=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(exist){
|
||||
Dialogs.showAlertDialog(context, 'Cant duplicate entries!', 'Journal entry was found on this date, Please edit that instead of adding new entry.');
|
||||
return;
|
||||
}
|
||||
await User.UserOperations.addJournal(date, title, text);
|
||||
}
|
||||
Navigator.of(context).popUntil((route) {
|
||||
|
||||
@@ -120,7 +120,7 @@ class _ProjectsState extends State<Projects> {
|
||||
),
|
||||
Divider(),
|
||||
Container(
|
||||
height: 100,
|
||||
height: 200,
|
||||
child: ListView.builder(
|
||||
itemCount: User.projects.length,
|
||||
itemBuilder: (context,index){
|
||||
|
||||
@@ -134,18 +134,18 @@ Future<void> refreshUserData({bool forceOffline = false}) async {
|
||||
if(forceOffline) {
|
||||
refreshStream.add(true);
|
||||
categories = await GetCategories(true);
|
||||
projects= await GetProjects(true);
|
||||
taskTypes = await GetTaskTypes(true);
|
||||
activities = await GetActivities(true);
|
||||
projects= await GetProjects(true);
|
||||
journal = await GetJournals(true);
|
||||
|
||||
refreshStream.add(false);
|
||||
}else{
|
||||
|
||||
categories = await GetCategories(false);
|
||||
projects= await GetProjects(false);
|
||||
taskTypes = await GetTaskTypes(false);
|
||||
activities = await GetActivities(false);
|
||||
projects= await GetProjects(false);
|
||||
journal = await GetJournals(false);
|
||||
|
||||
}
|
||||
@@ -1314,6 +1314,16 @@ class UserOperations {
|
||||
}
|
||||
|
||||
static Future<void> addJournal(DateTime day, String title, String text) async {
|
||||
|
||||
bool exist =false;
|
||||
for (var element in journal) {
|
||||
if(element.day== day){
|
||||
//Wat!
|
||||
exist=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(exist){return;}
|
||||
String id = username + DateFormat('yyyy-MM-dd').format(day);
|
||||
Map<String, String> queryBody = <String, String>{
|
||||
'username': username,
|
||||
|
||||
Reference in New Issue
Block a user