pomotime: time format

그루두·2023년 12월 19일


남은 시간은 정수형 변수에 저장되기 때문에 시계 형식(00:00)으로 전환해서 화면에 나타냈다.

  String getTimeFormat(int sec) {
    return Duration(seconds: sec).toString().substring(2, 7);
  }

getTimeFormat 함수를 설정해 정수를 전달하면 그 초를 분:초 형태로 return하여 화면에 나타냈다.

https://github.com/soaringwave/pomotime/commit/71c0064597b36224fcf36c7de0fa714fb5f7c2b0

해당 함수는 total time(총 작업 시간) 구현 후 수정을 거쳤다.

total time의 경우 시간이 누적될수록 분 단위를 넘어 시간도 표시되어야 하기 때문에 return 값을 시:분:초 형태로 변경했다. 하지만 work, rest는 1시간 이상으로 설정할 수 없기 때문에 기존처럼 표현되도록 문자열을 잘라서 화면에 나타낸다.

					// ...
                      child: Text(
                        getTimeFormat(leftTime).substring(2),
                        style: const TextStyle(
                          fontSize: 40,
                        ),
                      ),
                      // ...

https://github.com/soaringwave/pomotime/commit/f7685832d402164df7700b2914c08cd83745e642

profile
계속 해보자

0개의 댓글