2021-07-24 18:55:13 +08:00
|
|
|
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
2021-07-13 08:47:26 +08:00
|
|
|
import 'package:flowy_infra/size.dart';
|
|
|
|
|
import 'package:flowy_infra/time/duration.dart';
|
2021-07-12 23:27:58 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
// ignore: import_of_legacy_library_into_null_safe
|
|
|
|
|
import 'package:sized_context/sized_context.dart';
|
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
|
|
|
|
|
|
import 'home_sizes.dart';
|
|
|
|
|
|
|
|
|
|
class HomeLayout {
|
|
|
|
|
late double menuWidth;
|
|
|
|
|
late bool showMenu;
|
|
|
|
|
late bool showEditPannel;
|
|
|
|
|
late double editPannelWidth;
|
|
|
|
|
late double homePageLOffset;
|
|
|
|
|
late double homePageROffset;
|
|
|
|
|
late Duration animDuration;
|
|
|
|
|
|
2021-10-11 09:05:53 +08:00
|
|
|
HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint, bool forceCollapse) {
|
2021-07-12 23:27:58 +08:00
|
|
|
final homeBlocState = context.read<HomeBloc>().state;
|
|
|
|
|
|
|
|
|
|
showEditPannel = homeBlocState.editContext.isSome();
|
|
|
|
|
|
2021-07-25 23:12:58 +08:00
|
|
|
menuWidth = Sizes.sideBarMed;
|
2021-07-12 23:27:58 +08:00
|
|
|
if (context.widthPx >= PageBreaks.desktop) {
|
|
|
|
|
menuWidth = Sizes.sideBarLg;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-20 23:51:08 +08:00
|
|
|
if (forceCollapse) {
|
|
|
|
|
showMenu = false;
|
|
|
|
|
} else {
|
|
|
|
|
showMenu = context.widthPx > PageBreaks.tabletPortrait;
|
|
|
|
|
}
|
2021-07-12 23:27:58 +08:00
|
|
|
|
|
|
|
|
homePageLOffset = showMenu ? menuWidth : 0.0;
|
|
|
|
|
animDuration = .35.seconds;
|
|
|
|
|
|
|
|
|
|
editPannelWidth = HomeSizes.editPannelWidth;
|
|
|
|
|
homePageROffset = showEditPannel ? editPannelWidth : 0;
|
|
|
|
|
}
|
|
|
|
|
}
|