97 lines
3.4 KiB
Dart
97 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import './todo_model.dart';
|
|
|
|
class TodoDetail extends StatelessWidget {
|
|
final Todo todo;
|
|
|
|
const TodoDetail({required this.todo, super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(todo.taskName, overflow: TextOverflow.ellipsis),
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
// 任務標題
|
|
Text(
|
|
todo.taskName,
|
|
style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold, color: Colors.black87),
|
|
),
|
|
const Divider(height: 24.0),
|
|
|
|
// 任務屬性表格 (簡潔顯示)
|
|
_buildAttributeRow(context, '狀態', todo.status ?? 'N/A', todo.statusColor),
|
|
_buildAttributeRow(context, '優先級', todo.priority ?? 'N/A', Colors.red),
|
|
_buildAttributeRow(context, '截止日期', todo.formattedEndDate, Colors.blue),
|
|
_buildAttributeRow(context, '建立者', todo.createdBy ?? 'N/A', Colors.grey),
|
|
_buildAttributeRow(context, '分類', todo.className, Colors.purple),
|
|
|
|
const Divider(height: 32.0),
|
|
|
|
// 詳細說明
|
|
const Text(
|
|
'詳細說明:',
|
|
style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w600, color: Colors.black87),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
todo.description ?? '無詳細說明。',
|
|
style: const TextStyle(fontSize: 16.0, height: 1.5, color: Colors.black54),
|
|
textAlign: TextAlign.justify,
|
|
),
|
|
const SizedBox(height: 40),
|
|
|
|
// 底部按鈕 (例如:標記完成)
|
|
Center(
|
|
child: ElevatedButton.icon(
|
|
onPressed: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text('已標記任務 "${todo.taskName}" 待實作更新狀態。')),
|
|
);
|
|
// 實際應用中,這裡會呼叫 API 更新 pbi_status 為 'DONE'
|
|
},
|
|
icon: const Icon(Icons.check_circle_outline),
|
|
label: const Text('標記為已完成'),
|
|
style: ElevatedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
|
|
backgroundColor: Colors.green,
|
|
foregroundColor: Colors.white,
|
|
textStyle: const TextStyle(fontSize: 18),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildAttributeRow(BuildContext context, String label, String value, Color color) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: 8.0),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
width: 100,
|
|
child: Text(
|
|
'$label:',
|
|
style: const TextStyle(fontWeight: FontWeight.w500, color: Colors.black),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
value,
|
|
style: TextStyle(fontWeight: FontWeight.w600, color: color),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |