修改幾個小 issue
This commit is contained in:
+26
-13
@@ -1,4 +1,4 @@
|
||||
// todo_form.dart (適配 Todo Model)
|
||||
// todo_form.dart (適配 Todo Model - 中文化與選項調整)
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -21,8 +21,10 @@ class _TodoFormState extends State<TodoForm> {
|
||||
final TextEditingController _nameController = TextEditingController();
|
||||
final TextEditingController _descController = TextEditingController();
|
||||
|
||||
String _selectedClass = 'Work';
|
||||
String _selectedPriority = 'Medium';
|
||||
// 根據需求更新預設值與選項
|
||||
String _selectedClass = '工作';
|
||||
String _selectedPriority = 'Middle';
|
||||
String _selectedStatus = 'ToDo'; // 新增狀態變數
|
||||
DateTime _endDate = DateTime.now().add(const Duration(days: 7));
|
||||
|
||||
final Color primaryPurple = const Color(0xFF6542D0);
|
||||
@@ -53,7 +55,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
className: _selectedClass,
|
||||
description: _descController.text,
|
||||
priority: _selectedPriority,
|
||||
status: 'WIP',
|
||||
status: _selectedStatus, // 這裡改為帶入表單選擇的狀態
|
||||
endDate: _endDate,
|
||||
createdBy: widget.userId,
|
||||
);
|
||||
@@ -77,7 +79,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
appBar: AppBar(
|
||||
backgroundColor: bgLight, elevation: 0,
|
||||
leading: IconButton(icon: const Icon(Icons.arrow_back_ios_new, color: Colors.black87), onPressed: () => Navigator.pop(context)),
|
||||
title: const Text('New Task', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold)),
|
||||
title: const Text('新增任務', style: TextStyle(color: Colors.black87, fontWeight: FontWeight.bold)),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
@@ -87,15 +89,25 @@ class _TodoFormState extends State<TodoForm> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildDropdownField('Task Category', _selectedClass, ['Work', 'Personal', 'Urgent'], (val) => setState(() => _selectedClass = val!)),
|
||||
// 類別:改為 固定三個選項
|
||||
_buildDropdownField('任務類別', _selectedClass, ['工作', '個人行程', '其他'], (val) => setState(() => _selectedClass = val!)),
|
||||
const SizedBox(height: 20),
|
||||
_buildTextField('Task Name', _nameController, 'e.g. Design UI Mockup', Icons.edit_note),
|
||||
|
||||
// 名稱與說明:加上中文提示
|
||||
_buildTextField('任務名稱', _nameController, '例如:撰寫系統分析報告', Icons.edit_note),
|
||||
const SizedBox(height: 20),
|
||||
_buildTextField('Description', _descController, 'Enter details here...', Icons.description, isMultiline: true),
|
||||
_buildTextField('任務說明', _descController, '請輸入任務詳細說明...', Icons.description, isMultiline: true),
|
||||
const SizedBox(height: 20),
|
||||
_buildDropdownField('Priority', _selectedPriority, ['High', 'Medium', 'Low'], (val) => setState(() => _selectedPriority = val!)),
|
||||
|
||||
// 優先級:改為 High, Middle, Low
|
||||
_buildDropdownField('優先級', _selectedPriority, ['High', 'Middle', 'Low'], (val) => setState(() => _selectedPriority = val!)),
|
||||
const SizedBox(height: 20),
|
||||
_buildDatePicker('Due Date', _endDate),
|
||||
|
||||
// 新增狀態下拉選單
|
||||
_buildDropdownField('目前狀態', _selectedStatus, ['ToDo', 'WIP', 'Hold', 'Done'], (val) => setState(() => _selectedStatus = val!)),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
_buildDatePicker('截止日期', _endDate),
|
||||
const SizedBox(height: 40),
|
||||
_buildSubmitButton(),
|
||||
],
|
||||
@@ -119,7 +131,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
controller: controller,
|
||||
maxLines: isMultiline ? 3 : 1,
|
||||
decoration: InputDecoration(hintText: hint, border: InputBorder.none, isDense: true, contentPadding: const EdgeInsets.only(top: 8)),
|
||||
validator: (v) => v == null || v.isEmpty ? 'Cannot be empty' : null,
|
||||
validator: (v) => v == null || v.isEmpty ? '此欄位不能為空' : null, // 必填防呆中文化
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -155,7 +167,8 @@ class _TodoFormState extends State<TodoForm> {
|
||||
children: [
|
||||
Text(label, style: const TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
const SizedBox(height: 4),
|
||||
Text(DateFormat('dd MMM, yyyy').format(date), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
// 日期格式也順便調整成台灣習慣的 YYYY/MM/DD
|
||||
Text(DateFormat('yyyy/MM/dd').format(date), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
Icon(Icons.calendar_today, color: primaryPurple, size: 20),
|
||||
@@ -172,7 +185,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(backgroundColor: primaryPurple, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), elevation: 5),
|
||||
onPressed: _handleSubmit,
|
||||
child: const Text('Create Task', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white)),
|
||||
child: const Text('建立任務', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user