Skip to content

Commit

Permalink
Merge branch 'release/1.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
mouredev committed Jan 27, 2022
2 parents c2f486c + 9476124 commit 9a43159
Show file tree
Hide file tree
Showing 29 changed files with 511 additions and 120 deletions.
20 changes: 16 additions & 4 deletions Twitimer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
ACEE88AE2635E159007E9473 /* FirebaseRCService.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACEE88AD2635E159007E9473 /* FirebaseRCService.swift */; };
ACFCDD912631DF3100E9E270 /* SearchRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACFCDD902631DF3100E9E270 /* SearchRowView.swift */; };
ACFD66A82639648B00FC5D6B /* ImageExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACFD66A72639648B00FC5D6B /* ImageExtension.swift */; };
ACFED7B527332A9E00DE9207 /* InfoIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACFED7B427332A9E00DE9207 /* InfoIconView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -211,6 +212,7 @@
ACEE88AD2635E159007E9473 /* FirebaseRCService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirebaseRCService.swift; sourceTree = "<group>"; };
ACFCDD902631DF3100E9E270 /* SearchRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchRowView.swift; sourceTree = "<group>"; };
ACFD66A72639648B00FC5D6B /* ImageExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageExtension.swift; sourceTree = "<group>"; };
ACFED7B427332A9E00DE9207 /* InfoIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoIconView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -589,6 +591,7 @@
AC95848426329B1400DE4314 /* Info */ = {
isa = PBXGroup;
children = (
ACFED7B327332A8700DE9207 /* Views */,
AC95848526329B3D00DE4314 /* InfoView.swift */,
AC95849326329B6500DE4314 /* InfoViewModel.swift */,
AC95848B26329B5700DE4314 /* InfoRouter.swift */,
Expand Down Expand Up @@ -673,6 +676,14 @@
path = Fonts;
sourceTree = "<group>";
};
ACFED7B327332A8700DE9207 /* Views */ = {
isa = PBXGroup;
children = (
ACFED7B427332A9E00DE9207 /* InfoIconView.swift */,
);
path = Views;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -871,6 +882,7 @@
AC8681092631A9F600580B89 /* UserHeaderView.swift in Sources */,
AC8399C8263150FB00F0E8F1 /* AppDelegate.swift in Sources */,
ACEE88AE2635E159007E9473 /* FirebaseRCService.swift in Sources */,
ACFED7B527332A9E00DE9207 /* InfoIconView.swift in Sources */,
AC8681222631ACDE00580B89 /* CountdownRouter.swift in Sources */,
AC07A574267AA2950053B052 /* OnboardingPageView.swift in Sources */,
AC63915626D6AAFE005E4DFE /* SettingsViewModel.swift in Sources */,
Expand Down Expand Up @@ -1116,7 +1128,7 @@
"@executable_path/Frameworks",
);
MACH_O_TYPE = mh_execute;
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.mouredev.Twitimer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -1142,7 +1154,7 @@
"@executable_path/Frameworks",
);
MACH_O_TYPE = mh_execute;
MARKETING_VERSION = 1.2.3;
MARKETING_VERSION = 1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.mouredev.Twitimer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -1297,15 +1309,15 @@
repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git";
requirement = {
kind = exactVersion;
version = 8.7.0;
version = 8.9.1;
};
};
ACCD6F6926CD38B50069E5E8 /* XCRemoteSwiftPackageReference "Kingfisher" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/onevcat/Kingfisher";
requirement = {
kind = exactVersion;
version = 7.0.0;
version = 7.1.1;
};
};
ACCD6F6C26CD38D30069E5E8 /* XCRemoteSwiftPackageReference "SwiftUIRefresh" */ = {
Expand Down
23 changes: 23 additions & 0 deletions Twitimer/Assets.xcassets/Icon/holiday.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "holiday.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "holiday@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "holiday@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions Twitimer/Assets.xcassets/Images/vacation.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "vacation.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
73 changes: 73 additions & 0 deletions Twitimer/Assets.xcassets/Images/vacation.imageset/vacation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Twitimer/Model/Domain/DatabaseUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct DatabaseUserSchedule: Codable {

struct DatabaseUserSettings: Codable {

var onHolidays: Int?
var discord: String?
var youtube: String?
var twitter: String?
Expand All @@ -58,7 +59,7 @@ struct DatabaseUserSettings: Codable {

func toUserSettings() -> UserSettings {

return UserSettings(discord: discord ?? "", youtube: youtube ?? "", twitter: twitter ?? "", instagram: instagram ?? "", tiktok: tiktok ?? "")
return UserSettings(onHolidays: onHolidays == 1, discord: discord ?? "", youtube: youtube ?? "", twitter: twitter ?? "", instagram: instagram ?? "", tiktok: tiktok ?? "")
}

}
6 changes: 4 additions & 2 deletions Twitimer/Model/Domain/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ enum WeekdayType: Int, Codable, CaseIterable {

struct UserSettings: Codable, Equatable {

var onHolidays: Bool
var discord: String
var youtube: String
var twitter: String
Expand All @@ -234,7 +235,8 @@ struct UserSettings: Codable, Equatable {

func toJSON() -> [String:Any] {

return [DatabaseField.discord.rawValue:discord,
return [DatabaseField.onHolidays.rawValue:onHolidays ? 1 : 0,
DatabaseField.discord.rawValue:discord,
DatabaseField.youtube.rawValue:youtube,
DatabaseField.twitter.rawValue:twitter,
DatabaseField.instagram.rawValue:instagram,
Expand All @@ -246,6 +248,6 @@ struct UserSettings: Codable, Equatable {
// Empty UserSettings init
extension UserSettings {
init() {
self.init(discord: "", youtube: "", twitter: "", instagram: "", tiktok: "")
self.init(onHolidays: false, discord: "", youtube: "", twitter: "", instagram: "", tiktok: "")
}
}
50 changes: 39 additions & 11 deletions Twitimer/Model/Session/Session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ final class Session {
}
}

func delete(success: @escaping () -> Void) {

if let accessToken = token?.accessToken {
TwitchService.shared.revoke(accessToken: accessToken) {
self.remove(completion: success)
} failure: { (_) in
self.remove(completion: success)
}
}
}

func save(schedule: [UserSchedule]) {

if user?.schedule != schedule {
Expand Down Expand Up @@ -129,6 +140,9 @@ final class Session {
user?.followedUsers = []
}
user?.followedUsers?.append(login)
if streamers == nil {
streamers = []
}
streamers?.append(followedUser)

setupNotification(add: true, topic: login)
Expand Down Expand Up @@ -213,22 +227,25 @@ final class Session {

streamers.forEach { (streamer) in

var nextSchedule: UserSchedule?
if !(streamer.settings?.onHolidays ?? false) {

streamer.schedule?.forEach({ (schedule) in
var nextSchedule: UserSchedule?

if schedule.enable {

let weekDate = schedule.weekDate()
streamer.schedule?.forEach({ (schedule) in

if (nextSchedule == nil && weekDate > currentDate) || (weekDate > currentDate && weekDate < nextSchedule!.date) {
nextSchedule = schedule
if schedule.enable {

let weekDate = schedule.weekDate()

if (nextSchedule == nil && weekDate > currentDate) || (weekDate > currentDate && weekDate < nextSchedule!.date) {
nextSchedule = schedule
}
}
})

if let nextSchedule = nextSchedule {
sortedStreamings.append((streamer, nextSchedule))
}
})

if let nextSchedule = nextSchedule {
sortedStreamings.append((streamer, nextSchedule))
}
}

Expand Down Expand Up @@ -417,6 +434,17 @@ final class Session {
}
}

private func remove(completion: @escaping () -> Void) {

if let user = user {
FirebaseRDBService.shared.delete(user: user) {
self.clear(completion: completion)
} failure: { error in
self.clear(completion: completion)
}
}
}

private func clear(completion: @escaping () -> Void) {

user?.followedUsers?.forEach({ (user) in
Expand Down
17 changes: 16 additions & 1 deletion Twitimer/Provider/Services/Firebase/FirebaseRDBService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum DatabaseField: String {
case streamer
case schedule, enable, weekDay, date, duration, title // Schedule
case followedUsers
case settings, discord, youtube, twitter, instagram, tiktok // Settings
case settings, onHolidays, discord, youtube, twitter, instagram, tiktok // Settings
}

final class FirebaseRDBService {
Expand Down Expand Up @@ -142,4 +142,19 @@ final class FirebaseRDBService {
}
}

func delete(user: User, success: @escaping () -> Void, failure: @escaping (_ error: Error?) -> Void) {

if let login = user.login {
((user.streamer ?? false) ? streamersRef : usersRef).child(login).removeValue { error, _ in
if let error = error {
failure(error)
} else {
success()
}
}
} else {
failure(nil)
}
}

}
15 changes: 15 additions & 0 deletions Twitimer/SupportingFiles/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
"user.streamer" = "I'm a streamer";
"user.syncschedule.alert.title" = "Synchronize Twitch schedule";
"user.syncschedule.alert.body" = "Do you want to sync your recurring Twitch calendar? The Twitimer schedule will be overwritten.";
"user.scheduleinfo.alert.title" = "Schedules synchronization";
"user.scheduleinfo.alert.body" = "The schedules saved from Twitimer will not overwrite those of Twitch to avoid interfering with the platform and allow you to manage them in a more intuitive and agile way.";

// Info

Expand Down Expand Up @@ -93,6 +95,13 @@
"info.schedule.body" = "The streamer does not have available schedules. He may not have added them Twitimer yet (or he may be on holidays).";
"info.schedule.advice.1" = "Try checking them out later. When the streamer has a schedule, a countdown will appear in the list of upcoming broadcasts.";

"info.holiday.title" = "Holiday mode activated";
"info.holiday.body" = "Holiday mode hides your broadcast schedules from your followers and notifies your audience.";
"info.holiday.advice.1" = "Deactivate holiday mode from your user settings.";

"info.userholidays.body" = "This user is on holidays. Schedules will be displayed at the moment that the streamer returns.";
"info.userholidays.advice.1" = "If you have active notifications, you will receive a notification.";

// Menu

"menu.by" = "by";
Expand All @@ -103,10 +112,16 @@

// Settings

"settings.holiday.title" = "Holiday mode";
"settings.holiday.body" = "Holiday mode hides your broadcast schedules from your followers and notifies your audience.";
"settings.holiday.alert" = "Do you want to activate the holiday mode? Your followers will be notified.";
"settings.socialmedia" = "Social media";
"settings.discord.placeholder" = "Discord invitation link code";
"settings.youtube.placeholder" = "YouTube user";
"settings.twitter.placeholder" = "Twitter user";
"settings.instagram.placeholder" = "Instagram user";
"settings.tiktok.placeholder" = "TikTok user";
"settings.savesettings" = "Save settings";
"settings.deleteaccount.title" = "Delete account";
"settings.deleteaccount.button" = "Delete my Twitimer account";
"settings.deleteaccount.alert" = "Your Twitimer account and all their associated data will be deleted. Your Twitch account will not be affected.";
Loading

0 comments on commit 9a43159

Please sign in to comment.