Skip to content

Commit

Permalink
feat: improve landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
denysvitali committed Mar 26, 2024
1 parent 5234b73 commit f1ebc2c
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 311 deletions.
242 changes: 121 additions & 121 deletions lib/components/TaskBottomSheet.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:vikunja_app/components/label.dart';
import 'package:vikunja_app/models/task.dart';
import 'package:vikunja_app/pages/list/task_edit.dart';
import 'package:vikunja_app/stores/project_store.dart';
import 'package:vikunja_app/theme/constants.dart';
import 'package:vikunja_app/utils/priority.dart';

import '../models/label.dart';
import '../models/task.dart';
import '../pages/list/task_edit.dart';
import '../stores/project_store.dart';
import '../theme/constants.dart';
import 'label.dart';

class TaskBottomSheet extends StatefulWidget {
final Task task;
final bool showInfo;
Expand All @@ -26,129 +24,131 @@ class TaskBottomSheet extends StatefulWidget {
this.showInfo = false,
this.onMarkedAsDone,
}) : super(key: key);
/*
@override
TaskTileState createState() {
return new TaskTileState(this.task, this.loading);
}

*/
@override
TaskBottomSheetState createState() => TaskBottomSheetState(this.task);
TaskBottomSheetState createState() => TaskBottomSheetState();
}

class TaskBottomSheetState extends State<TaskBottomSheet> {
Task _currentTask;
late Task _currentTask;

TaskBottomSheetState(this._currentTask);
@override
void initState() {
super.initState();
_currentTask = widget.task;
}

@override
Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
return Container(
height: MediaQuery.of(context).size.height * 0.9,
child: Padding(
padding: EdgeInsets.fromLTRB(20, 10, 10, 20),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
// Title and edit button
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(_currentTask.title,
style: theme.textTheme.headlineLarge),
IconButton(
onPressed: () {
Navigator.push<Task>(
context,
MaterialPageRoute(
builder: (buildContext) => TaskEditPage(
task: _currentTask,
taskState: widget.taskState,
),
),
)
.then((task) => setState(() {
if (task != null) _currentTask = task;
}))
.whenComplete(() => widget.onEdit());
},
icon: Icon(Icons.edit)),
],
),
Wrap(
spacing: 10,
children: _currentTask.labels.map((Label label) {
return LabelComponent(
label: label,
);
}).toList()),
final theme = Theme.of(context);
return SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_currentTask.title,
style: theme.textTheme.headline6,
),
IconButton(
onPressed: _editTask,
icon: Icon(Icons.edit),
),
],
),
SizedBox(height: 16),
Wrap(
spacing: 8,
runSpacing: 8,
children: _currentTask.labels.map((label) {
return LabelComponent(label: label);
}).toList(),
),
HtmlWidget(
_currentTask.description.isNotEmpty
? _currentTask.description
: 'No description',
),
SizedBox(height: 16),
_buildRowWithIconAndText(
Icons.access_time,
_currentTask.dueDate != null
? vDateFormatShort.format(_currentTask.dueDate!.toLocal())
: 'No due date',
),
_buildRowWithIconAndText(
Icons.play_arrow_rounded,
_currentTask.startDate != null
? vDateFormatShort.format(_currentTask.startDate!.toLocal())
: 'No start date',
),
_buildRowWithIconAndText(
Icons.stop_rounded,
_currentTask.endDate != null
? vDateFormatShort.format(_currentTask.endDate!.toLocal())
: 'No end date',
),
_buildRowWithIconAndText(
Icons.priority_high,
_currentTask.priority != null
? priorityToString(_currentTask.priority)
: 'No priority',
),
_buildRowWithIconAndText(
Icons.percent,
_currentTask.percent_done != null
? '${(_currentTask.percent_done! * 100).toInt()}%'
: 'Unset',
),
],
),
),
);
}

void _editTask() {
Navigator.push<Task>(
context,
MaterialPageRoute(
builder: (buildContext) => TaskEditPage(
task: _currentTask,
taskState: widget.taskState,
),
),
).then((task) {
if (task != null) {
setState(() {
_currentTask = task;
});
}
widget.onEdit();
});
}

Widget _buildSectionTitle(String title) {
return Text(
title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
),
);
}

// description with html rendering
Text("Description", style: theme.textTheme.headlineSmall),
Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: HtmlWidget(_currentTask.description.isNotEmpty
? _currentTask.description
: "No description"),
),
// Due date
Row(
children: [
Icon(Icons.access_time),
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
Text(_currentTask.dueDate != null
? vDateFormatShort.format(_currentTask.dueDate!.toLocal())
: "No due date"),
],
),
// start date
Row(
children: [
Icon(Icons.play_arrow_rounded),
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
Text(_currentTask.startDate != null
? vDateFormatShort
.format(_currentTask.startDate!.toLocal())
: "No start date"),
],
),
// end date
Row(
children: [
Icon(Icons.stop_rounded),
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
Text(_currentTask.endDate != null
? vDateFormatShort.format(_currentTask.endDate!.toLocal())
: "No end date"),
],
),
// priority
Row(
children: [
Icon(Icons.priority_high),
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
Text(_currentTask.priority != null
? priorityToString(_currentTask.priority)
: "No priority"),
],
),
// progress
Row(
children: [
Icon(Icons.percent),
Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
Text(_currentTask.percent_done != null
? (_currentTask.percent_done! * 100).toInt().toString() +
"%"
: "Unset"),
],
),
],
),
));
Widget _buildRowWithIconAndText(IconData icon, String text) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
Icon(icon),
SizedBox(width: 8),
Text(text),
],
),
);
}
}
Loading

0 comments on commit f1ebc2c

Please sign in to comment.