Skip to content
Draft
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
24 changes: 19 additions & 5 deletions lib/cmd/ios_splash.dart
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the command adds duplicate image with id edQ-YT-iED

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit d214e27. Added logic to check for existing background image element in the storyboard before creating a new one, preventing duplicates.

Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ Future<void> updateContentOfStoryboard({
iosContentMode ?? IOSStrings.contentModeValue,
);

/// Remove existing or old constraints
view.children.remove(view.getElement(IOSStrings.constraintsElement));
/// Remove all existing constraints elements to avoid duplicates
view.children.removeWhere(
(node) =>
node is XmlElement &&
node.name.qualified == IOSStrings.constraintsElement,
);

/// Add constraints in view element
view.children.add(
Expand All @@ -189,7 +193,14 @@ Future<void> updateContentOfStoryboard({

final imageViewCopy = imageView?.copy();
imageView?.remove();

// Check if background image element already exists in the storyboard
if (backgroundImageElement == null) {
backgroundImageElement = getBackgroundImageElement(subViews);
}

if (backgroundImageElement == null) {
// Create new background image element only if it doesn't exist
backgroundImageElement = getImageXMLElement(
elementId: IOSStrings.backgroundImageViewIdValue,
imageName: IOSStrings.backgroundImage,
Expand All @@ -203,14 +214,17 @@ Future<void> updateContentOfStoryboard({
IosContentMode.fromString(iosBackgroundContentMode).mode,
);
}
log("BackgroundImage already exists. Background image wasn't set.");
}
if (imageViewCopy != null) subViews?.children.add(imageViewCopy);
} else {
/// Image is not available then
///
/// remove constraints
view.children.remove(view.getElement(IOSStrings.constraintsElement));
/// Remove all existing constraints elements
view.children.removeWhere(
(node) =>
node is XmlElement &&
node.name.qualified == IOSStrings.constraintsElement,
);

final subviewsTag =
documentData?.findAllElements(IOSStrings.subViewsElement).firstOrNull;
Expand Down