Skip to content

Commit

Permalink
Merge pull request #184 from Horizontal-org/develop
Browse files Browse the repository at this point in the history
1.10.0
  • Loading branch information
ValbuenaG authored Sep 16, 2024
2 parents abf8d9e + 5efa50e commit 0ab8cfe
Show file tree
Hide file tree
Showing 137 changed files with 6,081 additions and 2,044 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,5 @@ iOSInjectionProject/
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata
.idea

Tella/Supporting Files/TellaConfig.xcconfig
4 changes: 3 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ target 'Tella' do
pod 'SQLCipher', ">= 4.5.2"
pod 'ZIPFoundation'
pod 'Mantis', '~> 2.21.0'

pod 'GoogleSignIn'
pod 'GoogleAPIClientForREST/Drive'

target 'TellaTests' do
inherit! :search_paths
# Pods for testing
Expand Down
401 changes: 336 additions & 65 deletions Tella.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Tella/Application/TellaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct TellaApp: App {
UIApplication.getTopViewController()?.dismiss(animated: false)
self.saveData(lockApptype: .enterInBackground)
case .active:
UIApplication.getTopViewController()?.dismiss(animated: false)
self.resetApp()
case .inactive:
appViewState.homeViewModel.shouldShowSecurityScreen = true
Expand Down Expand Up @@ -72,7 +71,8 @@ struct TellaApp: App {
let shouldResetApp = appViewState.homeViewModel.shouldResetApp()

if shouldResetApp && appEnterInBackground && !hasFileOnBackground {

UIApplication.getTopViewController()?.dismiss(animated: false)

DispatchQueue.main.async {
appViewState.shouldHidePresentedView = true
appViewState.resetApp()
Expand Down
12 changes: 8 additions & 4 deletions Tella/Components/NavigationHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@ import SwiftUI

enum NavigationType {
case save
case draft
case validate
case reload
case none
case delete

var imageName: String {
switch self {
case .save: return "reports.save"
case .draft: return "reports.save"
case .validate: return "report.select-files"
case .reload: return "arrow.clockwise"
case .delete: return "report.delete-outbox"
case .none: return ""
case .none, .save: return ""
}
}

var backButtonIcon: String {
switch self {
case .save: return "close"
case .save, .draft: return "close"
default: return "back"
}
}
Expand All @@ -40,13 +41,14 @@ struct NavigationHeaderView: View {
var rightButtonAction: (() -> Void)?
var title: String = ""
var type: NavigationType
var isRightButtonEnabled: Bool = true

var body: some View {
HStack(spacing: 0) {
backButton
headerTitleView
Spacer()
if(type != .none) {
if(!type.imageName.isEmpty) {
rightButton
}
}.frame(height: 56)
Expand Down Expand Up @@ -78,7 +80,9 @@ struct NavigationHeaderView: View {
Image(type.imageName)
.resizable()
.frame(width: 24, height: 24)
.opacity(isRightButtonEnabled ? 1 : 0.4)
}
.disabled(!isRightButtonEnabled)
}
}

Expand Down
32 changes: 32 additions & 0 deletions Tella/Components/ServerConnectionHeaderView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// ServerConnectionHeaderView.swift
// Tella
//
// Created by gus valbuena on 5/29/24.
// Copyright © 2024 HORIZONTAL. All rights reserved.
//

import SwiftUI

struct ServerConnectionHeaderView: View {
var title: String
var subtitle: String
var body: some View {
VStack(spacing: 8) {
Image("gdrive.icon")
.padding(.bottom, 16)
Text(title)
.font(.custom(Styles.Fonts.semiBoldFontName, size: 18))
.foregroundColor(.white)
.multilineTextAlignment(.center)
Text(subtitle)
.font(.custom(Styles.Fonts.regularFontName, size: 14))
.foregroundColor(.white)
.multilineTextAlignment(.center)
}.padding(.horizontal, 20)
}
}

#Preview {
ServerConnectionHeaderView(title: "title", subtitle: "subtitle")
}
6 changes: 3 additions & 3 deletions Tella/Components/Tabs/PageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import SwiftUI
class PageViewItem {

var title : String
var page : Pages
var page : Page
var number : Int

init(title: String, page: Pages, number: Int) {
init(title: String, page: Page, number: Int) {
self.title = title
self.page = page
self.number = number
Expand All @@ -19,7 +19,7 @@ class PageViewItem {

public struct PageView: View {

@Binding var selectedOption: Pages
@Binding var selectedOption: Page
var pageViewItems : [PageViewItem]

public var body: some View {
Expand Down
4 changes: 2 additions & 2 deletions Tella/Components/Tabs/PageViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ struct PageViewCell: View {
let title: String
let number: Int

let page: Pages
let page: Page

@Binding var selectedOption: Pages
@Binding var selectedOption: Page

public var body: some View {

Expand Down
2 changes: 1 addition & 1 deletion Tella/Components/Tabs/Pages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public enum Pages: Hashable {
public enum Page: Hashable {

case draft
case outbox
Expand Down
46 changes: 26 additions & 20 deletions Tella/Components/ToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,37 @@
import SwiftUI

struct ToastView: View {

@State var isShowingView : Bool = true
var message : String
var width = CGFloat.infinity

var message: String
@State private var isShowing = true

var body: some View {

VStack {

Spacer()

Text(message)
.font(.custom(Styles.Fonts.regularFontName, size: 14))
.foregroundColor(.black)
.padding()
.frame(maxWidth: width)
.background(Color.white)
.cornerRadius(4)
.padding()
ZStack {
if isShowing {
Text(message)
.font(.custom(Styles.Fonts.regularFontName, size: 14))
.foregroundColor(.black)
.padding()
.frame(maxWidth: .infinity)
.background(Color.white)
.cornerRadius(4)
.padding()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
withAnimation {
isShowing = false
}
}
}
}
}
.padding()
}
}

struct ToastView_Previews: PreviewProvider {
static var previews: some View {
ToastView( message: "Message")
ZStack {
Styles.Colors.backgroundMain
ToastView( message: "Message")
}
}
}
10 changes: 9 additions & 1 deletion Tella/Data/Database/Common/DatabaseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct D {

/* DATABASE VERSION */

static let databaseVersion = 5
static let databaseVersion = 6

/* DEFAULT TYPES FOR DATABASE */
// MARK: - DEFAULT TYPES FOR DATABASE
Expand All @@ -34,6 +34,9 @@ struct D {
static let tUwaziEntityInstanceVaultFile = "t_uwazi_entity_instance_vault_file"
static let tFeedback = "t_feedback"
static let tResource = "t_resource"
static let tGDriveServer = "t_drive_server"
static let tGDriveReport = "t_drive_report_table"
static let tGDriveInstanceVaultFile = "t_drive_instance_vault_file"

/* DATABASE COLUMNS */
// MARK: - DATABASE COLUMNS
Expand Down Expand Up @@ -90,6 +93,11 @@ struct D {
static let cFilename = "c_filename"
static let cExternalId = "c_external_id"
static let cSize = "c_size"

//gDrive
static let cRootFolder = "c_root_folder_id"
static let cFolderId = "c_folder_id"
static let cRootFolderName = "c_root_folder_name"

}

Expand Down
8 changes: 0 additions & 8 deletions Tella/Data/Database/Common/SQLStatementBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ class SQLiteStatementBuilder {
}
}

func addColumnToExistingTable(tableName: String, column: String) {
let sqlExpression = "ALTER TABLE " + tableName + " ADD COLUMN " + column
let ret = sqlite3_exec(dbPointer, sqlExpression, nil, nil, nil)

if (ret != SQLITE_OK) { // corrupt database.
logDbErr("Error altering db table - \(tableName)")
}
}
func setNewDatabaseVersion(version:Int) throws {

let sql = ("PRAGMA user_version = \(version)")
Expand Down
73 changes: 73 additions & 0 deletions Tella/Data/Database/GDriveData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// GDriveData.swift
// Tella
//
// Created by gus valbuena on 6/28/24.
// Copyright © 2024 HORIZONTAL. All rights reserved.
//

import Foundation

extension TellaData {
func addGDriveReport(report : GDriveReport) -> Result<Int, Error> {
let id = database.addGDriveReport(report: report)

shouldReloadGDriveReports.send(true)

return id
}

func getDraftGDriveReport() -> [GDriveReport] {
return self.database.getDriveReports(reportStatus: [ReportStatus.draft])
}

func getOutboxedGDriveReport() -> [GDriveReport] {
return self.database.getDriveReports(reportStatus: [.finalized,
.submissionError,
.submissionPending,
.submissionPaused,
.submissionInProgress,
.submissionAutoPaused,
.submissionScheduled])
}

func getSubmittedGDriveReport() -> [GDriveReport] {
return self.database.getDriveReports(reportStatus: [ReportStatus.submitted])
}

func getDriveReport(id: Int?) -> GDriveReport? {
guard let id else { return nil }
return self.database.getGDriveReport(id: id)
}

func updateDriveReport(report: GDriveReport) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)
return self.database.updateDriveReport(report: report)
}

func deleteDriveReport(reportId: Int?) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)
return self.database.deleteDriveReport(reportId: reportId)
}

@discardableResult
func updateDriveReportStatus(reportId: Int, status: ReportStatus) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)

return self.database.updateDriveReportStatus(idReport: reportId, status: status)
}

@discardableResult
func updateDriveFolderId(reportId: Int, folderId: String) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)

return self.database.updateDriveReportFolderId(idReport: reportId, folderId: folderId)
}

@discardableResult
func updateDriveFiles(reportId: Int, files: [ReportFile]) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)

return self.database.updateDriveReportFiles(files: files, reportId: reportId)
}
}
Loading

0 comments on commit 0ab8cfe

Please sign in to comment.