Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix widget constraints #3709

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/Controllers/Map/OAMapHudViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<constraint firstAttribute="bottom" secondItem="2RZ-GK-954" secondAttribute="bottom" id="bNi-In-1bI"/>
<constraint firstItem="8m9-Ym-Yya" firstAttribute="top" secondItem="K8g-PT-gdL" secondAttribute="bottom" id="cXy-oN-mfY"/>
<constraint firstAttribute="rightMargin" secondItem="8m9-Ym-Yya" secondAttribute="right" constant="-10" id="cbg-nq-EYB"/>
<constraint firstItem="8m9-Ym-Yya" firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="2RZ-GK-954" secondAttribute="top" priority="999" id="kSQ-Gc-881"/>
<constraint firstItem="8m9-Ym-Yya" firstAttribute="bottom" relation="lessThanOrEqual" secondItem="2RZ-GK-954" secondAttribute="top" priority="999" id="kSQ-Gc-881"/>
<constraint firstItem="K8g-PT-gdL" firstAttribute="top" secondItem="w1v-g4-GFe" secondAttribute="top" id="l7W-kJ-xAQ"/>
<constraint firstItem="K8g-PT-gdL" firstAttribute="centerX" secondItem="w1v-g4-GFe" secondAttribute="centerX" id="nd0-KQ-Ihp"/>
<constraint firstAttribute="trailingMargin" secondItem="2RZ-GK-954" secondAttribute="trailing" priority="999" constant="-8" id="oaV-Cz-WGl"/>
Expand Down Expand Up @@ -279,7 +279,7 @@
<image name="ic_custom_search.png" width="30" height="30"/>
<image name="ic_custom_umbrella.png" width="30" height="30"/>
<namedColor name="widgetBgColor">
<color red="1" green="1" blue="1" alpha="0.93999999761581421" colorSpace="custom" customColorSpace="sRGB"/>
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
88 changes: 12 additions & 76 deletions Sources/Controllers/Map/OAMapInfoController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,7 @@ - (void)updateShadowView:(ShadowPathView *)view

- (void) layoutWidgets
{
BOOL portrait = ![OAUtilities isLandscape];

BOOL hasTopWidgets = [_topPanelController hasWidgets];
BOOL hasTopSpecialWidgets = [_topPanelController.specialPanelController hasWidgets];
BOOL hasLeftWidgets = [_leftPanelController hasWidgets];
BOOL hasBottomWidgets = [_bottomPanelController hasWidgets];
BOOL hasRightWidgets = [_rightPanelController hasWidgets];
[self configureLayerWidgets:hasTopWidgets];

if (_alarmControl && _alarmControl.superview && !_alarmControl.hidden)
Expand All @@ -420,63 +414,15 @@ - (void) layoutWidgets
_rulerControl.center = _rulerControl.superview.center;
}

_mapHudViewController.topWidgetsViewWidthConstraint.constant = [OAUtilities isLandscapeIpadAware] ? kInfoViewLandscapeWidthPad : DeviceScreenWidth;

if ((hasTopWidgets || hasTopSpecialWidgets) && _lastUpdateTime == 0)
if ((hasTopWidgets || [_topPanelController.specialPanelController hasWidgets]) && _lastUpdateTime == 0)
[[OARootViewController instance].mapPanel updateToolbar];

if (hasTopWidgets)
{
_mapHudViewController.topWidgetsViewHeightConstraint.constant = [_topPanelController calculateContentSize].height;
_mapHudViewController.topWidgetsView.layer.masksToBounds = NO;

[self updateShadowView:_topShadowContainerView direction:ShadowPathDirectionBottom];
}
else
{
_mapHudViewController.topWidgetsViewHeightConstraint.constant = 0.;
_mapHudViewController.topWidgetsView.layer.masksToBounds = YES;
}

if (hasTopSpecialWidgets)
{
_mapHudViewController.middleWidgetsViewYConstraint.constant = kWidgetsTopPadding;
CGSize specialPanelSize = [_topPanelController.specialPanelController calculateContentSize];
_mapHudViewController.middleWidgetsViewWidthConstraint.constant = specialPanelSize.width;
_mapHudViewController.middleWidgetsViewHeightConstraint.constant = specialPanelSize.height;
}
else
{
_mapHudViewController.middleWidgetsViewHeightConstraint.constant = 0.;
}

if (hasLeftWidgets)
{
CGSize leftSize = [_leftPanelController calculateContentSize];
CGFloat pageControlHeight = _leftPanelController.pages.count > 1 ? 16 : 0;
_mapHudViewController.leftWidgetsViewHeightConstraint.constant = leftSize.height + pageControlHeight + (_leftPanelController.view.layer.borderWidth * 2);
_mapHudViewController.leftWidgetsViewWidthConstraint.constant = leftSize.width;
}
else
{
_mapHudViewController.leftWidgetsViewHeightConstraint.constant = 0.;
_mapHudViewController.leftWidgetsViewWidthConstraint.constant = 0.;
}

_mapHudViewController.bottomWidgetsViewWidthConstraint.constant = [OAUtilities isLandscapeIpadAware] ? kInfoViewLandscapeWidthPad : DeviceScreenWidth;
if (hasBottomWidgets)
{
_mapHudViewController.bottomWidgetsViewHeightConstraint.constant = [_bottomPanelController calculateContentSize].height;
_mapHudViewController.bottomWidgetsView.layer.masksToBounds = NO;

[self updateShadowView:_bottomShadowContainerView direction:ShadowPathDirectionTop];
}
else
{
_mapHudViewController.bottomWidgetsViewHeightConstraint.constant = 0;
_mapHudViewController.bottomWidgetsView.layer.masksToBounds = YES;
}
_mapHudViewController.topWidgetsView.layer.masksToBounds = !hasTopWidgets;
[self updateShadowView:_topShadowContainerView direction:ShadowPathDirectionBottom];
_mapHudViewController.middleWidgetsViewYConstraint.constant = kWidgetsTopPadding;

_mapHudViewController.bottomWidgetsView.layer.masksToBounds = ![_bottomPanelController hasWidgets];
[self updateShadowView:_bottomShadowContainerView direction:ShadowPathDirectionTop];

OAMapRendererView *mapView = [OARootViewController instance].mapPanel.mapViewController.mapView;
CGFloat topOffset = _mapHudViewController.topWidgetsViewHeightConstraint.constant;
Expand All @@ -487,30 +433,19 @@ - (void) layoutWidgets
bottomOffset += _mapHudViewController.bottomBarViewHeightConstraint.constant;
[mapView setTopOffsetOfViewSize:topOffset bottomOffset:bottomOffset];

if (hasRightWidgets)
{
CGSize rightSize = [_rightPanelController calculateContentSize];
CGFloat pageControlHeight = _rightPanelController.pages.count > 1 ? 16 : 0;
_mapHudViewController.rightWidgetsViewHeightConstraint.constant = rightSize.height + pageControlHeight + (_rightPanelController.view.layer.borderWidth * 2);
_mapHudViewController.rightWidgetsViewWidthConstraint.constant = rightSize.width;
}
else
{
_mapHudViewController.rightWidgetsViewHeightConstraint.constant = 0.;
_mapHudViewController.rightWidgetsViewWidthConstraint.constant = 0.;
}
CGFloat leftRightWidgetsViewTopConstraintConstant = hasTopWidgets ? 1 : 0;
if ([OAUtilities isLandscapeIpadAware])
{
if (hasLeftWidgets)
if ([_leftPanelController hasWidgets] || [_rightPanelController hasWidgets])
{
leftRightWidgetsViewTopConstraintConstant = _mapHudViewController.topWidgetsViewHeightConstraint.constant > 0 ? -_mapHudViewController.topWidgetsViewHeightConstraint.constant : kWidgetsTopPadding;
} else
}
else
{
leftRightWidgetsViewTopConstraintConstant = -_mapHudViewController.topWidgetsViewHeightConstraint.constant + 16;
}
}

_mapHudViewController.leftWidgetsViewTopConstraint.constant =
_mapHudViewController.rightWidgetsViewTopConstraint.constant = leftRightWidgetsViewTopConstraintConstant;

Expand All @@ -519,7 +454,7 @@ - (void) layoutWidgets
if (_lastUpdateTime == 0)
[[OARootViewController instance].mapPanel updateToolbar];

if (portrait)
if (![OAUtilities isLandscape])
{
_downloadMapWidget.frame = CGRectMake(0, _mapHudViewController.statusBarView.frame.size.height, DeviceScreenWidth, 155.);
}
Expand Down Expand Up @@ -647,6 +582,7 @@ - (void) recreateControls:(BOOL)registerWidgets
[_mapWidgetRegistry updateWidgetsInfo:[[OAAppSettings sharedManager].applicationMode get]];

[self recreateWidgetsPanel:_topPanelController panel:OAWidgetsPanel.topPanel appMode:appMode];
[_topPanelController.specialPanelController updateWidgetSizes];
[self recreateWidgetsPanel:_bottomPanelController panel:OAWidgetsPanel.bottomPanel appMode:appMode];
[self recreateWidgetsPanel:_leftPanelController panel:OAWidgetsPanel.leftPanel appMode:appMode];
[self recreateWidgetsPanel:_rightPanelController panel:OAWidgetsPanel.rightPanel appMode:appMode];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Controllers/Map/Widgets/OATextInfoWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@property (nonatomic, strong, nullable) UILabel *titleOrEmptyLabel;
@property (nonatomic, strong, nullable) UILabel *unitOrEmptyLabel;
@property (nonatomic, strong, nullable) UILabel *valueLabel;
@property (nonatomic, strong, nullable) UIView *iconWidgetView;
@property (nonatomic, strong, nullable) UIStackView *iconWidgetStackView;
@property (nonatomic) OACommonWidgetSizeStyle *widgetSizePref;

@property (strong) BOOL(^updateInfoFunction)();
Expand Down
Loading