2021-07-12 15:27:58 +00:00
|
|
|
import 'package:app_flowy/home/application/home_bloc.dart';
|
2021-07-13 00:47:26 +00:00
|
|
|
import 'package:flowy_infra/size.dart';
|
|
|
|
import 'package:flowy_infra/time/duration.dart';
|
2021-07-12 15:27:58 +00: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-07-20 15:51:08 +00:00
|
|
|
HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint,
|
|
|
|
bool forceCollapse) {
|
2021-07-12 15:27:58 +00:00
|
|
|
final homeBlocState = context.read<HomeBloc>().state;
|
|
|
|
|
|
|
|
showEditPannel = homeBlocState.editContext.isSome();
|
|
|
|
|
|
|
|
menuWidth = Sizes.sideBarSm;
|
|
|
|
if (context.widthPx >= PageBreaks.desktop) {
|
|
|
|
menuWidth = Sizes.sideBarLg;
|
|
|
|
}
|
|
|
|
|
2021-07-20 15:51:08 +00:00
|
|
|
if (forceCollapse) {
|
|
|
|
showMenu = false;
|
|
|
|
} else {
|
|
|
|
showMenu = context.widthPx > PageBreaks.tabletPortrait;
|
|
|
|
}
|
2021-07-12 15:27:58 +00:00
|
|
|
|
|
|
|
homePageLOffset = showMenu ? menuWidth : 0.0;
|
|
|
|
animDuration = .35.seconds;
|
|
|
|
|
|
|
|
editPannelWidth = HomeSizes.editPannelWidth;
|
|
|
|
homePageROffset = showEditPannel ? editPannelWidth : 0;
|
|
|
|
}
|
|
|
|
}
|