Skip to content

Commit 22f549c

Browse files
committed
Add the example for macOS and the loader implementation
1 parent 8097e09 commit 22f549c

23 files changed

Lines changed: 1630 additions & 87 deletions

File tree

Example/Podfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use_frameworks!
22

3-
platform :ios, '13.0'
4-
53
target 'SDWebImageLinkPlugin_Example' do
4+
platform :ios, '13.0'
65
pod 'SDWebImageLinkPlugin', :path => '../'
76

87
target 'SDWebImageLinkPlugin_Tests' do
@@ -11,3 +10,8 @@ target 'SDWebImageLinkPlugin_Example' do
1110

1211
end
1312
end
13+
14+
target 'SDWebImageLinkPlugin_Example macOS' do
15+
platform :osx, '10.15'
16+
pod 'SDWebImageLinkPlugin', :path => '../'
17+
end

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ EXTERNAL SOURCES:
1818

1919
SPEC CHECKSUMS:
2020
SDWebImage: 7137d57385fb632129838c1e6ab9528a22c666cc
21-
SDWebImageLinkPlugin: 4c2015a316c599ee7757a6b1eae68531b04e4856
21+
SDWebImageLinkPlugin: ea390a828e8c0da400a4d113fbef334fab2b26d1
2222

23-
PODFILE CHECKSUM: 8765b147cfec3f0bf916e5813de13a381750b3b1
23+
PODFILE CHECKSUM: 74a62a3e72a34ed61a73510a4231db8d0408fcbe
2424

2525
COCOAPODS: 1.8.4

Example/SDWebImageLinkPlugin.xcodeproj/project.pbxproj

Lines changed: 237 additions & 4 deletions
Large diffs are not rendered by default.

Example/SDWebImageLinkPlugin.xcodeproj/xcshareddata/xcschemes/SDWebImageLinkPlugin-Example.xcscheme

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<MacroExpansion>
31+
<BuildableReference
32+
BuildableIdentifier = "primary"
33+
BlueprintIdentifier = "6003F589195388D20070C39A"
34+
BuildableName = "SDWebImageLinkPlugin_Example.app"
35+
BlueprintName = "SDWebImageLinkPlugin_Example"
36+
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
37+
</BuildableReference>
38+
</MacroExpansion>
3039
<Testables>
3140
<TestableReference
3241
skipped = "NO">
@@ -39,17 +48,6 @@
3948
</BuildableReference>
4049
</TestableReference>
4150
</Testables>
42-
<MacroExpansion>
43-
<BuildableReference
44-
BuildableIdentifier = "primary"
45-
BlueprintIdentifier = "6003F589195388D20070C39A"
46-
BuildableName = "SDWebImageLinkPlugin_Example.app"
47-
BlueprintName = "SDWebImageLinkPlugin_Example"
48-
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
49-
</BuildableReference>
50-
</MacroExpansion>
51-
<AdditionalOptions>
52-
</AdditionalOptions>
5351
</TestAction>
5452
<LaunchAction
5553
buildConfiguration = "Debug"
@@ -71,8 +69,6 @@
7169
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
7270
</BuildableReference>
7371
</BuildableProductRunnable>
74-
<AdditionalOptions>
75-
</AdditionalOptions>
7672
</LaunchAction>
7773
<ProfileAction
7874
buildConfiguration = "Release"
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1120"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "3253E10B2387EAC4007ACAD8"
18+
BuildableName = "SDWebImageLinkPlugin_Example macOS.app"
19+
BlueprintName = "SDWebImageLinkPlugin_Example macOS"
20+
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "3253E10B2387EAC4007ACAD8"
48+
BuildableName = "SDWebImageLinkPlugin_Example macOS.app"
49+
BlueprintName = "SDWebImageLinkPlugin_Example macOS"
50+
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "3253E10B2387EAC4007ACAD8"
65+
BuildableName = "SDWebImageLinkPlugin_Example macOS.app"
66+
BlueprintName = "SDWebImageLinkPlugin_Example macOS"
67+
ReferencedContainer = "container:SDWebImageLinkPlugin.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

Example/SDWebImageLinkPlugin/SDViewController.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,26 @@ @implementation SDViewController
2323
- (void)viewDidLoad
2424
{
2525
[super viewDidLoad];
26-
NSURL *url = [NSURL URLWithString:@"https://www.apple.com/"];
27-
// self.linkView = [[LPLinkView alloc] initWithURL:url];
26+
[SDImageLoadersManager.sharedManager addLoader:SDImageLinkLoader.sharedLoader];
27+
SDWebImageManager.defaultImageLoader = SDImageLoadersManager.sharedManager;
28+
29+
NSURL *url1 = [NSURL URLWithString:@"https://www.apple.com/iphone/"];
30+
NSURL *url2 = [NSURL URLWithString:@"https://webkit.org/"];
31+
self.linkView = [[LPLinkView alloc] initWithURL:url1];
2832
self.imageView = [[UIImageView alloc] init];
2933
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
30-
// [self.view addSubview:self.linkView];
34+
[self.view addSubview:self.linkView];
3135
[self.view addSubview:self.imageView];
32-
[SDImageLinkLoader.sharedLoader requestImageWithURL:url options:0 context:@{SDWebImageContextLinkRequestImageData: @(NO)} progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
33-
self.imageView.image = image;
36+
37+
[self.imageView sd_setImageWithURL:url2 completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
38+
NSLog(@"%@", @"LPMetadata image load success");
3439
}];
3540
}
3641

3742
- (void)viewDidLayoutSubviews {
3843
[super viewDidLayoutSubviews];
39-
// self.linkView.frame = CGRectMake(0, 0, 200, 200);
40-
self.imageView.frame = CGRectMake(0, 200, 400, 400);
41-
}
42-
43-
- (void)didReceiveMemoryWarning
44-
{
45-
[super didReceiveMemoryWarning];
46-
// Dispose of any resources that can be recreated.
44+
self.linkView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height / 2);
45+
self.imageView.frame = CGRectMake(0, self.view.bounds.size.height / 2, self.view.bounds.size.width, self.view.bounds.size.height / 2);
4746
}
4847

4948
@end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AppDelegate.h
3+
// SDWebImageLinkPlugin_Example macOS
4+
//
5+
// Created by 李卓立 on 2019/11/22.
6+
// Copyright © 2019 lizhuoli1126@126.com. All rights reserved.
7+
//
8+
9+
#import <Cocoa/Cocoa.h>
10+
11+
@interface AppDelegate : NSObject <NSApplicationDelegate>
12+
13+
14+
@end
15+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// AppDelegate.m
3+
// SDWebImageLinkPlugin_Example macOS
4+
//
5+
// Created by 李卓立 on 2019/11/22.
6+
// Copyright © 2019 lizhuoli1126@126.com. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
11+
@interface AppDelegate ()
12+
13+
@end
14+
15+
@implementation AppDelegate
16+
17+
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
18+
// Insert code here to initialize your application
19+
}
20+
21+
22+
- (void)applicationWillTerminate:(NSNotification *)aNotification {
23+
// Insert code here to tear down your application
24+
}
25+
26+
27+
@end
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)