feat(apps): 重构 UI 架构为 presentation 层并新增 l10n 国际化支持
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
class DayViewScale {
|
||||
static const double defaultHourHeight = 34.0;
|
||||
static const double minHourHeight = 34.0;
|
||||
static const double maxHourHeight = 68.0;
|
||||
|
||||
final double hourHeight;
|
||||
|
||||
const DayViewScale({required this.hourHeight});
|
||||
|
||||
factory DayViewScale.defaultScale() {
|
||||
return const DayViewScale(hourHeight: minHourHeight);
|
||||
}
|
||||
|
||||
DayViewScale copyWith({double? hourHeight}) {
|
||||
return DayViewScale(
|
||||
hourHeight: _clampHourHeight(hourHeight ?? this.hourHeight),
|
||||
);
|
||||
}
|
||||
|
||||
DayViewScale zoomByFactor(double factor) {
|
||||
if (factor <= 0) {
|
||||
return this;
|
||||
}
|
||||
return copyWith(hourHeight: hourHeight * factor);
|
||||
}
|
||||
|
||||
double pixelsForMinutes(int minutes) {
|
||||
return (minutes / 60) * hourHeight;
|
||||
}
|
||||
|
||||
double minutesForPixels(double pixels) {
|
||||
return (pixels / hourHeight) * 60;
|
||||
}
|
||||
|
||||
static double _clampHourHeight(double value) {
|
||||
return value.clamp(minHourHeight, maxHourHeight);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user