Skip to content
This repository has been archived by the owner on Jan 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #3 from realm-demos/mt/issue-2
Browse files Browse the repository at this point in the history
[WIP] fixes dynamic image reloading and resizing
  • Loading branch information
icanzilb authored Aug 15, 2017
2 parents e7e424f + 0e6605e commit fdbcfca
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
23 changes: 21 additions & 2 deletions Example/RealmContent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,22 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-RealmContent_Example/Pods-RealmContent_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework",
"${BUILT_PRODUCTS_DIR}/MMMarkdown/MMMarkdown.framework",
"${BUILT_PRODUCTS_DIR}/NSString+Color/NSString_Color.framework",
"${BUILT_PRODUCTS_DIR}/Realm/Realm.framework",
"${BUILT_PRODUCTS_DIR}/RealmContent/RealmContent.framework",
"${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Kingfisher.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MMMarkdown.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/NSString_Color.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmContent.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RealmSwift.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -379,13 +392,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RealmContent_Example-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
92A3FFBC474A2B332CB77CA9 /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -409,13 +425,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RealmContent_Tests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down
2 changes: 1 addition & 1 deletion RealmContent.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RealmContent'
s.version = '0.2.0'
s.version = '0.2.1'
s.summary = 'Realm powered content management system'

s.description = <<-DESC
Expand Down
6 changes: 2 additions & 4 deletions RealmContent/Core/View/ContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ public class ContentViewController: UIViewController, UITableViewDataSource, UIT
}
}

pageElementsUpdatesToken = page.elements
.filter(NSPredicate(format: "type in %@", ContentElement.Kind.allRawValues()))
.addNotificationBlock(applyChanges)
pageElementsUpdatesToken = page.elements.addNotificationBlock(applyChanges)
}

private func populateFrom(page: ContentPage) {
Expand All @@ -126,7 +124,7 @@ public class ContentViewController: UIViewController, UITableViewDataSource, UIT
}
}

private func applyChanges(_ changes: RealmCollectionChange<Results<ContentElement>>) {
private func applyChanges(_ changes: RealmCollectionChange<List<ContentElement>>) {
let section = 0

switch changes {
Expand Down
15 changes: 6 additions & 9 deletions RealmContent/Core/View/ImageContentCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@ public class ImageContentCell: UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

let marginGuide = contentView.layoutMarginsGuide

img.translatesAutoresizingMaskIntoConstraints = true
img.contentMode = .scaleAspectFit
img.frame = contentView.bounds.insetBy(dx: layoutMargins.left, dy: layoutMargins.top)
img.autoresizingMask = [.flexibleWidth, .flexibleHeight]

// configure titleLabel
contentView.addSubview(img)
img.translatesAutoresizingMaskIntoConstraints = false
img.leadingAnchor.constraint(equalTo: marginGuide.leadingAnchor).isActive = true
img.topAnchor.constraint(equalTo: marginGuide.topAnchor).isActive = true
img.trailingAnchor.constraint(equalTo: marginGuide.trailingAnchor).isActive = true
img.bottomAnchor.constraint(equalTo: marginGuide.bottomAnchor).isActive = true
heightConstraint = img.heightAnchor.constraint(equalToConstant: 20)

heightConstraint = contentView.heightAnchor.constraint(equalToConstant: 20)
heightConstraint.priority = 500
heightConstraint.isActive = true
}

Expand Down

0 comments on commit fdbcfca

Please sign in to comment.