Skip to content

Commit

Permalink
チケット管理画面のUI/UXの改善
Browse files Browse the repository at this point in the history
  • Loading branch information
Aoi-Takahashi committed Mar 19, 2024
1 parent 5decb76 commit f73c35b
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 129 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ packages = ["src/pm_kun"]

[tool.rye.scripts]
check = "mypy --strict src/pm_kun/__init__.py"
view = "flet run src/pm_kun/screen/main.py --directory --recursive"
view = "flet run src/pm_kun/__init__.py --directory --recursive"
85 changes: 37 additions & 48 deletions src/pm_kun/__init__.py
Original file line number Diff line number Diff line change
@@ -1,55 +1,44 @@
import datetime
from typing import Optional
from pm_kun.pmgpt.main import generate_response
from pm_kun.screen.main import main as Screen
from pm_kun.task.todo import BaseTask
from pm_kun.type_definition import Priority, Status, ToDo
import uuid
import flet as ft
from pm_kun.screen.bord import view_chart
from pm_kun.screen.home import view_home
from pm_kun.screen.pmk import pmk
from pm_kun.screen.task import view_task

# TODO: PMK画面の実装を完成させる

def main() -> None:
print("This is Entory point for pm-kun.")
is_process = False
my_task = BaseTask()

def main(page: ft.Page) -> None:
# question = input("質問を入力してください")
# context = input("コンテキストを入力してください")
# print(generate_response(user_input=question, user_context=context))
Screen
# while is_process:
# print("1.タスクの追加")
# print("2.タスクの削除")
# print("3.タスクの更新")
# print("4.終了")
# select = input("選択してください")
# if select == "1":
# task = input("タスクを入力してください")
# my_Todo: ToDo = {
# "id": str(uuid.uuid4()),
# "task": "",
# "status": Status.未着手,
# "period": datetime.date.today(),
# "priority": Priority.低,
# }
# my_Todo["id"] = str(uuid.uuid4())
# my_Todo["task"] = task
# my_task.add_task(my_Todo)
# print(f"TODOの数:{len(my_task.todo_list)}")
# print(my_task.todo_list)
# elif select == "2":
# task = input("削除するタスクを入力してください")
# for todo in my_task.todo_list:
# if task in todo["task"]:
# id = todo["id"]
# my_task.delete_task(id)
# print(my_task.todo_list)
# elif select == "3":
# cuurent_task = input("更新するタスクを入力してください")
# update_task = input("更新後のタスクを入力してください")
# for todo in my_task.todo_list:
# if cuurent_task in todo["task"]:
# id = todo["id"]
# my_task.update_task(id, task=update_task)
# print(my_task.todo_list)
# elif select == "4":
# break
page.title = "プロマネ君"
page.window_width = 1050
page.window_height = 800
page.data = []

def route_change(route) -> None:
page.views.clear()
page.views.append(view_home(page))
if page.route == "/todo":
page.views.append(view_task(page))
if page.route == "/chart":
page.views.append(view_chart(page))
if page.route == "/pmk":
page.views.append(pmk(page))
page.update()

def view_pop(view) -> None:
page.views.pop()
top_view = page.views[-1]
page.go(top_view.route)

page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)


ft.app(target=main)

if __name__ == "__main__":
ft.app(target=main)
76 changes: 54 additions & 22 deletions src/pm_kun/screen/bord.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,22 @@


def view_chart(page: ft.Page):
todos_high = ft.Column()
todos_normal = ft.Column()
todos_complete = ft.Column()
todos_unselected = ft.Column(
expand=True,
scroll=ft.ScrollMode.AUTO,
)
todos_high = ft.Column(
expand=True,
scroll=ft.ScrollMode.AUTO,
)
todos_normal = ft.Column(
expand=True,
scroll=ft.ScrollMode.AUTO,
)
todos_complete = ft.Column(
expand=True,
scroll=ft.ScrollMode.AUTO,
)

def complete_ticket(parent_container: Union[ft.Column, ft.Row], control_id: str):
def handler(e):
Expand All @@ -24,6 +37,13 @@ def handler(e):
content=Ticket(
title=src.content.title,
id=src.content.id,
on_positive_button_click=complete_ticket(
todos_complete, src.content.id
),
on_negative_button_click=delete_ticket(
todos_complete, src.content.id
),
origin_container=todos_complete,
),
)
todos_complete.controls.append(completed_task)
Expand Down Expand Up @@ -56,11 +76,14 @@ def drag_accept(
src.content.origin_container.update()

if from_container == "high":
src.content.origin_container = "high"
src.content.origin_container = todos_high
elif from_container == "normal":
src.content.origin_container = "normal"
src.content.origin_container = todos_normal
elif from_container == "complete":
src.content.origin_container = "complete"
src.content.origin_container = todos_complete
else:
src.content.origin_container = todos_unselected

accept_task = Draggable(
group="task",
content=Ticket(
Expand All @@ -72,32 +95,41 @@ def drag_accept(
on_negative_button_click=delete_ticket(
target_container, src.content.id
),
origin_container=target_container,
origin_container=src.content.origin_container,
),
)
target_container.controls.append(accept_task)
target_container.update()

for control in unselected_todos.controls:
if control.content.id == src.content.id:
unselected_todos.controls.remove(control)
break
unselected_todos.update()

back_button = ft.ElevatedButton("メニューに戻る", on_click=lambda _: page.go("/"))

unselected_todos = ft.ListView(
width=250,
controls=[
for data in page.data:
todos_unselected.controls.append(
Draggable(
data=f"{data['name']}|{data['id']}",
group="task",
content=Ticket(title=data["name"], id=data["id"]),
content=Ticket(
title=data["name"],
id=data["id"],
on_positive_button_click=complete_ticket(
todos_unselected, data["id"]
),
on_negative_button_click=delete_ticket(
todos_unselected, data["id"]
),
origin_container=todos_unselected,
),
)
for data in page.data
],
expand=1,
auto_scroll=True,
)

area_unselected = ft.DragTarget(
group="task",
content=ft.Container(
content=todos_unselected,
width=250,
height=600,
),
on_accept=lambda e: drag_accept(todos_unselected, "none", e),
)

label_high = ft.Text("重要", size=20, text_align="center")
Expand Down Expand Up @@ -152,7 +184,7 @@ def drag_accept(
)

display = ft.Row(
controls=[unselected_todos, area_high, area_normal, area_complete],
controls=[area_unselected, area_high, area_normal, area_complete],
alignment="center",
)

Expand Down
7 changes: 0 additions & 7 deletions src/pm_kun/screen/component/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@


class Ticket(UserControl):
"""
・チケットの表示構成
 ①TODO名:TextField
 ②期限:DatePicker
 ③完了/削除:IconButton
 ④完了/削除ボタンを押したら、TODOを完了/削除する
"""

def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions src/pm_kun/screen/component/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def build(self):
def add_clicked(self, e):
task = Task(self.new_task.value, self.task_delete, self.update_task_data)
self.tasks.controls.append(task)
self._todos.append({"id": task.id, "name": task.task_name, "completed": False})
self._todos.append({"id": task.id, "name": task.task_name})
self.new_task.value = ""
self.update()

Expand All @@ -118,7 +118,7 @@ def update_task_data(self, task_id, new_name):
print(self._todos)

def task_delete(self, task):
self._todos = [task for t in self._todos if t["id"] != task.id]
self._todos = [t for t in self._todos if t["id"] != task.id]
self.tasks.controls.remove(task)
self.update()

Expand Down
47 changes: 0 additions & 47 deletions src/pm_kun/screen/main.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/pm_kun/screen/task.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import flet as ft
from flet_core import Control, UserControl

from pm_kun.screen.component.todo import Todo
from pm_kun.screen.util.create_view import create_view

Expand Down

0 comments on commit f73c35b

Please sign in to comment.