Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
L
liberty-tunnel-client-library-apple
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liberty
tunnel
liberty-tunnel-client-library-apple
Commits
c369d583
Commit
c369d583
authored
Nov 12, 2020
by
Jose Blaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InApp messages
parent
c9484de2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
7 deletions
+57
-7
PIALibrary/Sources/Core/Tiles/AvailableTiles.swift
PIALibrary/Sources/Core/Tiles/AvailableTiles.swift
+5
-0
PIALibrary/Sources/Core/Tiles/TileProvider.swift
PIALibrary/Sources/Core/Tiles/TileProvider.swift
+3
-0
PIALibrary/Sources/Core/WebServices/InAppMessage.swift
PIALibrary/Sources/Core/WebServices/InAppMessage.swift
+3
-3
PIALibrary/Sources/Library/Tiles/DefaultTileProvider.swift
PIALibrary/Sources/Library/Tiles/DefaultTileProvider.swift
+7
-0
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
+2
-2
PIALibrary/Sources/Mock/MockAccountProvider.swift
PIALibrary/Sources/Mock/MockAccountProvider.swift
+3
-1
PIALibrary/Sources/Mock/MockTileProvider.swift
PIALibrary/Sources/Mock/MockTileProvider.swift
+2
-0
PIALibrary/Sources/Mock/MockWebServices.swift
PIALibrary/Sources/Mock/MockWebServices.swift
+6
-1
PIALibrary/Sources/UI/iOS/Notification+UI.swift
PIALibrary/Sources/UI/iOS/Notification+UI.swift
+3
-0
PIALibrary/Sources/UI/iOS/Theme.swift
PIALibrary/Sources/UI/iOS/Theme.swift
+23
-0
No files found.
PIALibrary/Sources/Core/Tiles/AvailableTiles.swift
View file @
c369d583
...
...
@@ -31,6 +31,11 @@ public enum AvailableTiles: Int, EnumsBuilder {
case
quickSettings
case
favoriteServers
case
connectionTile
case
messages
public
static
func
fixedTiles
()
->
[
AvailableTiles
]
{
return
[
.
messages
]
}
public
static
func
allTiles
()
->
[
AvailableTiles
]
{
return
[
.
region
,
.
quickConnect
,
.
ip
,
.
subscription
,
.
usage
,
.
quickSettings
,
.
favoriteServers
,
.
connectionTile
]
...
...
PIALibrary/Sources/Core/Tiles/TileProvider.swift
View file @
c369d583
...
...
@@ -28,6 +28,9 @@ public protocol TileProvider: class {
/// the visible tiles in the dashboard.
var
visibleTiles
:
[
AvailableTiles
]
{
get
set
}
/// the fixed tiles in the dashboard.
var
fixedTiles
:
[
AvailableTiles
]
{
get
}
/// the order of the tiles to appear in the dashboard.
var
orderedTiles
:
[
AvailableTiles
]
{
get
set
}
...
...
PIALibrary/Sources/Core/WebServices/InAppMessage.swift
View file @
c369d583
...
...
@@ -45,7 +45,7 @@ public struct InAppMessage {
public
let
settingView
:
String
?
public
let
settingLink
:
String
?
init
(
withMessage
message
:
[
String
:
String
],
id
:
String
,
link
:
[
String
:
String
],
type
:
InAppMessageType
,
level
:
InAppMessageLevel
,
actions
:
[
String
:
Bool
]?,
view
:
String
?,
uri
:
String
?)
{
public
init
(
withMessage
message
:
[
String
:
String
],
id
:
String
,
link
:
[
String
:
String
],
type
:
InAppMessageType
,
level
:
InAppMessageLevel
,
actions
:
[
String
:
Bool
]?,
view
:
String
?,
uri
:
String
?)
{
self
.
id
=
id
self
.
message
=
message
self
.
linkMessage
=
link
...
...
@@ -60,9 +60,9 @@ public struct InAppMessage {
extension
InAppMessage
{
init
(
withMessage
messageInformation
:
Message
sInformation
.
Message
,
andLevel
level
:
InAppMessageLevel
)
{
init
(
withMessage
messageInformation
:
Message
Information
,
andLevel
level
:
InAppMessageLevel
)
{
self
.
id
=
"messageInformation.id"
self
.
id
=
messageInformation
.
id
self
.
message
=
messageInformation
.
message
self
.
linkMessage
=
messageInformation
.
link
.
text
...
...
PIALibrary/Sources/Library/Tiles/DefaultTileProvider.swift
View file @
c369d583
...
...
@@ -43,6 +43,13 @@ class DefaultTileProvider: TileProvider, DatabaseAccess {
}
}
// MARK: TileProvider
var
fixedTiles
:
[
AvailableTiles
]
{
get
{
return
AvailableTiles
.
fixedTiles
()
}
}
// MARK: TileProvider
var
orderedTiles
:
[
AvailableTiles
]
{
get
{
...
...
PIALibrary/Sources/Library/WebServices/PIAWebServices.swift
View file @
c369d583
...
...
@@ -425,14 +425,14 @@ class PIAWebServices: WebServices, ConfigurationAccess {
if
let
token
=
Client
.
providers
.
accountProvider
.
token
{
self
.
accountAPI
.
message
s
(
token
:
token
,
callback
:
{
(
messages
,
error
)
in
self
.
accountAPI
.
message
(
token
:
token
,
callback
:
{
(
message
,
error
)
in
if
let
error
=
error
{
callback
?(
nil
,
ClientError
.
malformedResponseData
)
return
}
if
let
message
=
message
s
.
first
{
if
let
message
=
message
{
let
inAppMessage
=
InAppMessage
(
withMessage
:
message
,
andLevel
:
.
api
)
callback
?(
inAppMessage
,
nil
)
}
else
{
...
...
PIALibrary/Sources/Mock/MockAccountProvider.swift
View file @
c369d583
...
...
@@ -311,6 +311,8 @@ public class MockAccountProvider: AccountProvider, WebServicesConsumer {
}
public
func
inAppMessages
(
_
callback
:
LibraryCallback
<
InAppMessage
>
?)
{
callback
?(
nil
,
nil
)
delegate
.
inAppMessages
{
(
message
,
error
)
in
callback
?(
message
,
error
)
}
}
}
PIALibrary/Sources/Mock/MockTileProvider.swift
View file @
c369d583
...
...
@@ -26,6 +26,8 @@ public class MockTileProvider: TileProvider {
public
var
visibleTiles
:
[
AvailableTiles
]
=
AvailableTiles
.
defaultTiles
()
public
var
fixedTiles
:
[
AvailableTiles
]
=
AvailableTiles
.
fixedTiles
()
public
var
orderedTiles
:
[
AvailableTiles
]
=
AvailableTiles
.
defaultOrderedTiles
()
/// :nodoc:
...
...
PIALibrary/Sources/Mock/MockWebServices.swift
View file @
c369d583
...
...
@@ -24,6 +24,8 @@ import Foundation
class
MockWebServices
:
WebServices
{
var
messageType
:
InAppMessageType
=
.
view
var
credentials
:
(()
->
Credentials
)?
var
accountInfo
:
(()
->
AccountInfo
)?
...
...
@@ -136,7 +138,10 @@ class MockWebServices: WebServices {
}
func
messages
(
_
callback
:
LibraryCallback
<
InAppMessage
>
?)
{
callback
?(
InAppMessage
(
withMessage
:
[
"en"
:
"Message"
],
id
:
"123"
,
link
:
[
"en"
:
"Message"
],
type
:
.
link
,
level
:
.
api
,
actions
:
nil
,
view
:
nil
,
uri
:
"https://www.privateinternetaccess.com"
),
nil
)
let
testLink
=
InAppMessage
(
withMessage
:
[
"en"
:
"This is a message"
],
id
:
"1"
,
link
:
[
"en"
:
"message"
],
type
:
.
link
,
level
:
.
api
,
actions
:
nil
,
view
:
nil
,
uri
:
"https://www.privateinternetaccess.com"
)
callback
?(
testLink
,
nil
)
}
}
PIALibrary/Sources/UI/iOS/Notification+UI.swift
View file @
c369d583
...
...
@@ -35,6 +35,9 @@ public extension Notification.Name {
/// Reload the tiles.
static
let
PIATilesDidChange
=
Notification
.
Name
(
"PIATilesDidChange"
)
/// Reload the tiles with animation.
static
let
PIAUpdateFixedTiles
=
Notification
.
Name
(
"PIAUpdateFixedTiles"
)
/// Present Recover Signup page
static
let
PIARecoverAccount
=
Notification
.
Name
(
"PIARecoverAccount"
)
...
...
PIALibrary/Sources/UI/iOS/Theme.swift
View file @
c369d583
...
...
@@ -502,6 +502,29 @@ public class Theme {
return
attributed
}
public
func
messageWithLinkText
(
withMessage
message
:
String
,
link
:
String
)
->
NSAttributedString
{
let
plain
=
message
.
replacingOccurrences
(
of
:
"$1"
,
with
:
link
)
as
NSString
let
attributed
=
NSMutableAttributedString
(
string
:
plain
as
String
)
let
paragraph
=
NSMutableParagraphStyle
()
paragraph
.
alignment
=
.
center
paragraph
.
minimumLineHeight
=
16
let
fullRange
=
NSMakeRange
(
0
,
plain
.
length
)
attributed
.
addAttribute
(
.
font
,
value
:
UIFont
.
regularFontWith
(
size
:
14
),
range
:
fullRange
)
if
Theme
.
current
.
palette
.
appearance
==
.
dark
{
attributed
.
addAttribute
(
.
foregroundColor
,
value
:
UIColor
.
white
,
range
:
fullRange
)
}
else
{
attributed
.
addAttribute
(
.
foregroundColor
,
value
:
UIColor
.
piaGrey6
,
range
:
fullRange
)
}
attributed
.
addAttribute
(
.
paragraphStyle
,
value
:
paragraph
,
range
:
fullRange
)
let
range1
=
plain
.
range
(
of
:
link
)
attributed
.
addAttribute
(
.
link
,
value
:
link
,
range
:
range1
)
return
attributed
}
// MARK: Composite
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment