Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-ios
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-ios
Commits
14ca2ca3
Commit
14ca2ca3
authored
1 year ago
by
Kateryna Kostiuk
Browse files
Options
Downloads
Patches
Plain Diff
donations: add settings in account
Change-Id: I15ff958e64bb298914bc2db188bd5fde0928bd49
parent
b7c7c656
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Ring/Ring/Features/Me/Me/MeViewController.swift
+48
-0
48 additions, 0 deletions
Ring/Ring/Features/Me/Me/MeViewController.swift
Ring/Ring/Features/Me/Me/MeViewModel.swift
+54
-6
54 additions, 6 deletions
Ring/Ring/Features/Me/Me/MeViewModel.swift
with
102 additions
and
6 deletions
Ring/Ring/Features/Me/Me/MeViewController.swift
+
48
−
0
View file @
14ca2ca3
...
...
@@ -683,6 +683,10 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
.
configureTurnCell
(
cellType
:
.
turnRealm
,
value
:
self
.
viewModel
.
turnRealm
.
value
)
return
cell
case
.
donationCampaign
:
return
self
.
createDonationNotificationCell
()
case
.
donate
:
return
self
.
createDonationCell
()
}
}
...
...
@@ -695,6 +699,50 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
.
disposed
(
by
:
disposeBag
)
}
func
createDonationCell
()
->
UITableViewCell
{
let
cell
=
DisposableCell
()
cell
.
textLabel
?
.
text
=
L10n
.
Global
.
donate
cell
.
textLabel
?
.
textColor
=
UIColor
.
jamiButtonDark
cell
.
textLabel
?
.
textAlignment
=
.
center
cell
.
textLabel
?
.
numberOfLines
=
0
cell
.
selectionStyle
=
.
none
cell
.
sizeToFit
()
let
button
=
UIButton
.
init
(
frame
:
cell
.
frame
)
let
size
=
CGSize
(
width
:
self
.
settingsTable
.
frame
.
width
,
height
:
button
.
frame
.
height
)
button
.
frame
.
size
=
size
cell
.
addSubview
(
button
)
button
.
rx
.
tap
.
subscribe
(
onNext
:
{
[
weak
self
]
in
self
?
.
viewModel
.
donate
()
})
.
disposed
(
by
:
cell
.
disposeBag
)
cell
.
backgroundColor
=
.
clear
cell
.
contentView
.
backgroundColor
=
.
systemBackground
return
cell
}
func
createDonationNotificationCell
()
->
DisposableCell
{
let
cell
=
DisposableCell
()
cell
.
textLabel
?
.
text
=
L10n
.
GeneralSettings
.
enableDonationCampaign
let
switchView
=
UISwitch
()
cell
.
selectionStyle
=
.
none
cell
.
accessoryType
=
UITableViewCell
.
AccessoryType
.
disclosureIndicator
cell
.
accessoryView
=
switchView
self
.
viewModel
.
enableDonationCampaign
.
asObservable
()
.
observe
(
on
:
MainScheduler
.
instance
)
.
startWith
(
viewModel
.
enableDonationCampaign
.
value
)
.
bind
(
to
:
switchView
.
rx
.
value
)
.
disposed
(
by
:
cell
.
disposeBag
)
switchView
.
rx
.
value
.
observe
(
on
:
MainScheduler
.
instance
)
.
subscribe
(
onNext
:
{
[
weak
self
]
(
enabled
)
in
self
?
.
viewModel
.
togleEnableDonationCampaign
(
enable
:
enabled
)
})
.
disposed
(
by
:
cell
.
disposeBag
)
return
cell
}
func
configureCellWithEnableTextCopy
(
text
:
String
,
secondaryText
:
String
,
style
:
UIFont
.
TextStyle
)
->
DisposableCell
{
let
cell
=
DisposableCell
(
style
:
.
subtitle
,
reuseIdentifier
:
self
.
jamiIDCell
)
cell
.
selectionStyle
=
.
none
...
...
This diff is collapsed.
Click to expand it.
Ring/Ring/Features/Me/Me/MeViewModel.swift
+
54
−
6
View file @
14ca2ca3
...
...
@@ -37,6 +37,7 @@ enum SettingsSection: SectionModelType {
case
connectivitySettings
(
items
:
[
SectionRow
])
case
credentials
(
items
:
[
SectionRow
])
case
otherSettings
(
items
:
[
SectionRow
])
case
donations
(
items
:
[
SectionRow
])
case
removeAccountSettings
(
items
:
[
SectionRow
])
enum
SectionRow
{
...
...
@@ -67,11 +68,20 @@ enum SettingsSection: SectionModelType {
case
turnPassword
case
turnRealm
case
upnpEnabled
case
donationCampaign
case
donate
}
var
items
:
[
SectionRow
]
{
switch
self
{
case
.
linkedDevices
(
let
items
),
.
removeAccountSettings
(
items
:
let
items
),
.
notificationSettings
(
let
items
),
.
connectivitySettings
(
let
items
),
.
credentials
(
let
items
),
.
otherSettings
(
items
:
let
items
),
.
accountSettings
(
items
:
let
items
):
case
.
linkedDevices
(
let
items
),
.
removeAccountSettings
(
items
:
let
items
),
.
notificationSettings
(
let
items
),
.
connectivitySettings
(
let
items
),
.
credentials
(
let
items
),
.
otherSettings
(
items
:
let
items
),
.
accountSettings
(
items
:
let
items
),
.
donations
(
items
:
let
items
):
return
items
}
}
...
...
@@ -90,7 +100,9 @@ enum SettingsSection: SectionModelType {
return
L10n
.
AccountPage
.
connectivityHeader
case
.
credentials
:
return
L10n
.
AccountPage
.
credentialsHeader
case
.
accountSettings
(
items
:
let
items
):
case
.
donations
(
items
:
_
):
return
L10n
.
Global
.
donate
case
.
accountSettings
(
items
:
_
):
return
nil
}
}
...
...
@@ -111,6 +123,8 @@ enum SettingsSection: SectionModelType {
self
=
.
otherSettings
(
items
:
items
)
case
.
removeAccountSettings
(
items
:
let
items
):
self
=
.
removeAccountSettings
(
items
:
items
)
case
.
donations
(
items
:
let
items
):
self
=
.
donations
(
items
:
items
)
}
}
}
...
...
@@ -207,6 +221,20 @@ class MeViewModel: ViewModel, Stateable {
.
just
(
.
notificationSettings
(
items
:
[
.
notifications
]))
}()
lazy
var
donationsSettings
:
Observable
<
SettingsSection
>
=
{
var
items
:
[
SettingsSection
.
SectionRow
]
=
[]
if
!
PreferenceManager
.
isReachEndOfDonationCampaign
()
{
items
.
append
(
contentsOf
:
[
.
donationCampaign
])
}
items
.
append
(
contentsOf
:
[
.
donate
])
return
Observable
.
just
(
.
donations
(
items
:
items
))
}()
lazy
var
connectivitySettings
:
Observable
<
SettingsSection
>
=
{
var
server
=
""
var
username
=
""
...
...
@@ -261,11 +289,12 @@ class MeViewModel: ViewModel, Stateable {
lazy
var
jamiSettings
:
Observable
<
[
SettingsSection
]
>
=
{
Observable
.
combineLatest
(
accountCredentials
,
linkedDevices
,
donationsSettings
,
accountJamiSettings
,
connectivitySettings
,
otherJamiSettings
,
removeAccountSettings
)
{
(
credentials
,
devices
,
settings
,
connectivity
,
other
,
removeAccount
)
in
return
[
credentials
,
devices
,
settings
,
connectivity
,
other
,
removeAccount
]
removeAccountSettings
)
{
(
credentials
,
devices
,
donate
,
settings
,
connectivity
,
other
,
removeAccount
)
in
return
[
credentials
,
devices
,
donate
,
settings
,
connectivity
,
other
,
removeAccount
]
}
}()
...
...
@@ -323,8 +352,9 @@ class MeViewModel: ViewModel, Stateable {
lazy
var
sipSettings
:
Observable
<
[
SettingsSection
]
>
=
{
Observable
.
combineLatest
(
sipCredentials
,
otherSipSettings
)
{
(
credentials
,
other
)
in
return
[
credentials
,
other
]
donationsSettings
,
otherSipSettings
)
{
(
credentials
,
donate
,
other
)
in
return
[
credentials
,
donate
,
other
]
}
}()
...
...
@@ -354,6 +384,7 @@ class MeViewModel: ViewModel, Stateable {
self
.
contactService
=
injectionBag
.
contactsService
self
.
presenceService
=
injectionBag
.
presenceService
self
.
secureTextEntry
.
onNext
(
true
)
self
.
enableDonationCampaign
=
BehaviorRelay
<
Bool
>
(
value
:
PreferenceManager
.
isCampaignEnabled
())
}
func
updateDataFor
(
account
:
AccountModel
)
{
...
...
@@ -554,6 +585,8 @@ class MeViewModel: ViewModel, Stateable {
let
currentAccountProxy
=
PublishSubject
<
Bool
>
()
let
currentAccountState
=
PublishSubject
<
AccountState
>
()
var
enableDonationCampaign
:
BehaviorRelay
<
Bool
>
lazy
var
accountState
:
Observable
<
AccountState
>
=
{
var
state
=
AccountState
.
registered
if
let
account
=
self
.
accountService
.
currentAccount
{
...
...
@@ -807,6 +840,21 @@ class MeViewModel: ViewModel, Stateable {
keepAliveEnabled
.
accept
(
enable
)
}
func
donate
()
{
SharedActionsPresenter
.
openDonationLink
()
}
func
togleEnableDonationCampaign
(
enable
:
Bool
)
{
if
enableDonationCampaign
.
value
==
enable
{
return
}
PreferenceManager
.
setCampaignEnabled
(
enable
)
if
enable
{
PreferenceManager
.
setStartDonationDate
(
DefaultValues
.
donationStartDate
)
}
enableDonationCampaign
.
accept
(
enable
)
}
// MARK: Connectivity
lazy
var
turnEnabled
:
BehaviorRelay
<
Bool
>
=
{
if
let
account
=
self
.
accountService
.
currentAccount
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment