feat: timer field (#5349)

* feat: wip timer field

* feat: timer field fixing errors

* feat: wip timer field frontend

* fix: parsing TimerCellDataPB

* feat: parse time string to minutes

* fix: don't allow none number input

* fix: timer filter

* style: cargo fmt

* fix: clippy errors

* refactor: rename field type timer to time

* refactor: missed some variable and files to rename

* style: cargo fmt fix

* feat: format time field type data in frontend

* style: fix cargo fmt

* fix: fixes after merge

---------

Co-authored-by: Mathias Mogensen <mathiasrieckm@gmail.com>
This commit is contained in:
Mohammad Zolfaghari
2024-06-13 10:22:13 +03:30
committed by GitHub
parent 2d4300e931
commit aa621a8d84
57 changed files with 1579 additions and 26 deletions

View File

@ -0,0 +1,24 @@
import 'package:appflowy/util/time.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('parseTime should parse time string to minutes', () {
expect(parseTime('10'), 10);
expect(parseTime('70m'), 70);
expect(parseTime('4h 20m'), 260);
expect(parseTime('1h 80m'), 140);
expect(parseTime('asffsa2h3m'), null);
expect(parseTime('2h3m'), null);
expect(parseTime('blah'), null);
expect(parseTime('10a'), null);
expect(parseTime('2h'), 120);
});
test('formatTime should format time minutes to formatted string', () {
expect(formatTime(5), "5m");
expect(formatTime(75), "1h 15m");
expect(formatTime(120), "2h");
expect(formatTime(-50), "");
expect(formatTime(0), "0m");
});
}