Skip to content

Feature/p2p #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 130 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
e2fdccd
Implement p2p main view
dhekra-rouatbi Feb 3, 2025
329a35b
Add Wifi connection Screen and permessions
Rimktarii Feb 5, 2025
f6723b2
Update WifiConnectionView
Rimktarii Feb 5, 2025
85d73f0
Add RegularTextView and Create ConnectToDeviceView Screen
Rimktarii Feb 5, 2025
f58bd4c
Create ConnectToDeviceView
Rimktarii Feb 5, 2025
300808a
Create ConnectToDeviceManuallyView
Rimktarii Feb 6, 2025
bf8e496
Add Nearby Sharing to connections
Rimktarii Feb 6, 2025
0d96043
Create secondary Tella button type
Rimktarii Feb 7, 2025
03e71ac
Rename Classes
Rimktarii Feb 7, 2025
af2532e
Update Views names and Add New Sender classes
Rimktarii Feb 10, 2025
ed30885
Add RecipientConnectToDeviceManuallyView
Rimktarii Feb 10, 2025
ff0e204
Fix PeerToPeer design and update the destination
Rimktarii Feb 11, 2025
696c024
Handle navigation
Rimktarii Feb 11, 2025
7ced0bd
Add waiting screen and adapt TellaButtonView
Rimktarii Feb 14, 2025
898c431
Create RecipientFilesRequestView screen
Rimktarii Feb 14, 2025
e6d2d68
Implement QRCodeScanner and QRCodeGenerator
dhekra-rouatbi Feb 14, 2025
947c52d
Validate fields in SenderConnectToDeviceManuallyView
Rimktarii Feb 25, 2025
0c72b28
Delete Tella/Components/WifiConnexionView.swift
Rimktarii Feb 25, 2025
695d815
Fix TellaButtonView height
Rimktarii Feb 25, 2025
52f5654
Create a generic AddFileView ( AddFileBottomSheetView and AddFileGrid…
Rimktarii Feb 26, 2025
9893903
Refactor Add Files in draftviews
Rimktarii Feb 27, 2025
18bad86
Fix add file in uwazi (Refacor)
Rimktarii Feb 28, 2025
38d91d4
Generate QR code with device ip address and sha256 of generated certi…
dhekra-rouatbi Mar 11, 2025
2738a76
Implement Register API
dhekra-rouatbi Apr 1, 2025
8886fce
Implement Connection failed, Handle server errors, update p2p main vi…
dhekra-rouatbi Apr 3, 2025
967825a
Update strings, organise files and update design
dhekra-rouatbi Apr 3, 2025
47a6e54
Improve code and start working on prepare upload API
dhekra-rouatbi Apr 7, 2025
623fc5e
Update Prepare upload models
dhekra-rouatbi Apr 7, 2025
d7cc8b6
Working on Prepare upload
dhekra-rouatbi Apr 8, 2025
3405aee
Fix register API issue
dhekra-rouatbi Apr 8, 2025
d036517
Fix register API issue
dhekra-rouatbi Apr 9, 2025
912d30b
Fix crash
dhekra-rouatbi Apr 10, 2025
aebac5e
Fix certificate
dhekra-rouatbi Apr 10, 2025
6500e5c
Working on certificate
dhekra-rouatbi Apr 10, 2025
3879f42
Fix server response
dhekra-rouatbi Apr 11, 2025
bb0b29e
Fix server response
dhekra-rouatbi Apr 11, 2025
25fd9dc
Fix server response
dhekra-rouatbi Apr 14, 2025
f8fa161
Refactor certificate generator
dhekra-rouatbi Apr 14, 2025
22ea67b
Code improvement
dhekra-rouatbi Apr 15, 2025
4fcec25
Code improvement
dhekra-rouatbi Apr 15, 2025
dbe53d6
Update Algorithm to RSA
dhekra-rouatbi Apr 15, 2025
9c35f11
Code improvement
dhekra-rouatbi Apr 15, 2025
48b41c7
Implement manually connection
dhekra-rouatbi Apr 17, 2025
b07c50e
Integrate typography styles into P2P views
dhekra-rouatbi Apr 23, 2025
54a6d60
Integrate typography styles into P2P views
dhekra-rouatbi Apr 23, 2025
f5ec596
Integrate typography styles into P2P views and Code improvement
dhekra-rouatbi Apr 23, 2025
6b192a3
Update hash format
dhekra-rouatbi Apr 23, 2025
999c976
Update QRCode size and Fix arrows orientation in Tips to connect view
dhekra-rouatbi Apr 24, 2025
c68ccb2
Fix conflict
dhekra-rouatbi Apr 30, 2025
2a52f2d
Update connect manually scenario
dhekra-rouatbi May 13, 2025
9b417cc
Implement prepare upload: API, server response and UI
dhekra-rouatbi May 16, 2025
f00aa42
Improve code
dhekra-rouatbi May 16, 2025
62ee776
Improve code
dhekra-rouatbi May 16, 2025
e12fff4
Handle errors in prepare upload
dhekra-rouatbi May 19, 2025
dcf1402
Update forbidden error message
dhekra-rouatbi May 19, 2025
17057aa
Refactor the P2P server class and handle the sender's discard respons…
dhekra-rouatbi May 19, 2025
302aecc
Handle discard and start over action
dhekra-rouatbi May 20, 2025
3e6ec47
Handle close connection API and generate server response
dhekra-rouatbi May 20, 2025
81c3123
Handle back button actions
dhekra-rouatbi May 21, 2025
1e01e02
Refactor PeertoPeerServer
dhekra-rouatbi May 22, 2025
62fcde6
Update the manual connection process
dhekra-rouatbi May 30, 2025
b589548
remove unused code
dhekra-rouatbi Jun 2, 2025
ef80d73
Update PeerToPeerRepository class name
dhekra-rouatbi Jun 2, 2025
213bdae
Refactor HTTP request parsing on the server to use the llhttp library
dhekra-rouatbi Jun 3, 2025
a6b6bbf
Refactor HTTP Response Builder
dhekra-rouatbi Jun 3, 2025
eda5a00
Add AnyView to some View
dhekra-rouatbi Jun 4, 2025
97ed7f0
Working on p2p
dhekra-rouatbi Jun 4, 2025
cac3410
Add ping endpoint
dhekra-rouatbi Jun 9, 2025
9d9ec5c
Add constants
dhekra-rouatbi Jun 9, 2025
5562c12
delete unnecessary debugs
dhekra-rouatbi Jun 9, 2025
8f3d749
unwrap the clientIdentity with a guard statement
dhekra-rouatbi Jun 9, 2025
0bb2075
Throw an error if there is an error on parsing: llhttp_execute
dhekra-rouatbi Jun 9, 2025
f4c4c02
Working on upload files and manual connection
dhekra-rouatbi Jun 23, 2025
70563fd
Update certificate hash text alignment
dhekra-rouatbi Jun 23, 2025
482c216
Refactor the server parameters into distinct classes
dhekra-rouatbi Jun 25, 2025
efe0f34
WIP on handle File Upload
dhekra-rouatbi Jun 26, 2025
7877802
handle File Upload : Working on the parser
dhekra-rouatbi Jun 27, 2025
d214b63
Delete unused code
dhekra-rouatbi Jun 30, 2025
45b031c
handle File Upload : Working on the parser
dhekra-rouatbi Jun 30, 2025
c0d2eaf
Update hash
dhekra-rouatbi Jun 30, 2025
f19a1c1
generate hash of the entire certificate instead of hashing only the p…
ValbuenaG Jun 30, 2025
891c062
Update hash
dhekra-rouatbi Jul 1, 2025
512c941
Working on receiving files and display the progress
dhekra-rouatbi Jul 9, 2025
43991e1
Improvement
dhekra-rouatbi Jul 9, 2025
a5a7063
Code improvement
dhekra-rouatbi Jul 9, 2025
b3501e2
Saving the received files
dhekra-rouatbi Jul 9, 2025
b4019dc
Progress flow and results view
dhekra-rouatbi Jul 16, 2025
44337de
Update design
dhekra-rouatbi Jul 16, 2025
32c9e6b
Remove back buttons
dhekra-rouatbi Jul 16, 2025
4f0744e
Update typography
dhekra-rouatbi Jul 16, 2025
4df7b9f
Fix styles
dhekra-rouatbi Jul 17, 2025
bb98851
Add missing title to sender progress view
dhekra-rouatbi Jul 17, 2025
5a59c4d
Fix back actions
dhekra-rouatbi Jul 17, 2025
98d4a56
Fix back actions
dhekra-rouatbi Jul 17, 2025
fdedce5
Update p2pLearnMore link
dhekra-rouatbi Jul 17, 2025
3ba43ba
Update parser
dhekra-rouatbi Jul 17, 2025
adc1286
Fix parser
dhekra-rouatbi Jul 17, 2025
5369d6d
Stop the server listener after finishing transfer
dhekra-rouatbi Jul 21, 2025
94e40bf
Centralise the server instance and improve code
dhekra-rouatbi Jul 23, 2025
7dbf325
update listener?.cancel() with stopListening
dhekra-rouatbi Jul 23, 2025
8292979
clean code
dhekra-rouatbi Jul 23, 2025
1d8fd69
Build 1.16.0(97)
dhekra-rouatbi Jul 23, 2025
d0b12d9
Add status icon and server initialisation
dhekra-rouatbi Jul 24, 2025
50e0651
Improve code
dhekra-rouatbi Jul 24, 2025
b0f138e
Move PeerToPeerEvent to another class
dhekra-rouatbi Jul 25, 2025
01ad56a
Show the QRCode only if the server started
dhekra-rouatbi Jul 25, 2025
17e1a14
Improve code
dhekra-rouatbi Jul 25, 2025
b13c627
Improve code
dhekra-rouatbi Jul 25, 2025
f9876f7
Add configureGoogleSignIn function to avoid crash when login to Googl…
dhekra-rouatbi Jul 25, 2025
559b6f0
Fix baseConfigurationReference
dhekra-rouatbi Jul 25, 2025
3d379ce
Fix trim audio bug
dhekra-rouatbi Jul 25, 2025
8c8e193
Build 98
dhekra-rouatbi Jul 25, 2025
288495d
WIP cancel receiving files
dhekra-rouatbi Jul 26, 2025
da7e555
Add scroll to Sender prepare file transfer view
dhekra-rouatbi Jul 27, 2025
58bd433
Fix fields validation
dhekra-rouatbi Jul 27, 2025
2a671bb
Fix closeConnection issue
dhekra-rouatbi Jul 28, 2025
e66091b
Improve NetworkManager
dhekra-rouatbi Jul 29, 2025
23a7c3d
Improvements
dhekra-rouatbi Jul 29, 2025
f1d9ddc
Improve NetworkManager
dhekra-rouatbi Jul 29, 2025
2e32798
Add connections queue
dhekra-rouatbi Jul 29, 2025
752ea96
update the completion with async/await
dhekra-rouatbi Jul 29, 2025
77eb4cc
Revert "update the completion with async/await"
dhekra-rouatbi Jul 29, 2025
e353f45
Revert "Add connections queue"
dhekra-rouatbi Jul 29, 2025
8659661
Update p2p learn more link
dhekra-rouatbi Jul 30, 2025
1462c58
Fix the QRCode initialisation
dhekra-rouatbi Jul 30, 2025
f2004c9
update the completion with async/await
dhekra-rouatbi Jul 30, 2025
f438b75
update the completion with async/await
dhekra-rouatbi Jul 30, 2025
875abd8
update the completion with async/await
dhekra-rouatbi Jul 31, 2025
e5ce3f5
Merge branch 'release/1.16.0(97)' into feature/p2p
dhekra-rouatbi Aug 1, 2025
7ec5a1e
Add the "Add button" to home view
dhekra-rouatbi Aug 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
448 changes: 430 additions & 18 deletions Tella.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// AddFileBottomSheetView.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI

struct AddFileBottomSheetView<Content: View>: View {

@ObservedObject var viewModel: AddFilesViewModel
@EnvironmentObject var sheetManager: SheetManager
var content: () -> Content
var moreAction: (() -> ())? = nil

init(viewModel: AddFilesViewModel, content: @escaping () -> Content, moreAction: (() -> ())? = nil ) {
self.viewModel = viewModel
self.content = content
self.moreAction = moreAction
}
var body: some View {
Button {
UIApplication.shared.endEditing()
moreAction?()
showAddFileSheet()
} label: {
content()
}
}

func showAddFileSheet() {
sheetManager.showBottomSheet(modalHeight: CGFloat(viewModel.bottomSheetItems.count * 50 + 90), content: {
ActionListBottomSheet(items: viewModel.bottomSheetItems,
headerTitle: LocalizableVault.manageFilesSheetTitle.localized,
action: { item in
self.handleActions(item: item)
})
})
}

private func handleActions(item: ListActionSheetItem) {
guard let type = item.type as? ManageFileType else { return }

switch type {
case .camera:
viewModel.showingCamera = true

case .recorder:
viewModel.showingRecordView = true

case .fromDevice:
showAddPhotoVideoSheet()

case .tellaFile:
navigateTo(destination: fileListView)

default:
break
}
sheetManager.hide()
}

func showAddPhotoVideoSheet() {
viewModel.showingImagePicker = true
}

var fileListView: some View {
FileListView(appModel: viewModel.mainAppModel,
filterType: viewModel.shouldShowDocumentsOnly ? .documents : .audioPhotoVideo,
title: LocalizableReport.selectFiles.localized,
fileListType: .selectFiles,
resultFile: $viewModel.resultFile)
}
}
24 changes: 24 additions & 0 deletions Tella/Components/AddFileGridViewComponent/AddFileCameraView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// AddFileCameraView.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI
struct AddFileCameraView: View {
@ObservedObject var viewModel: AddFilesViewModel

var sourceView = SourceView.addFile

var body: some View {
viewModel.showingCamera ?
CameraView(sourceView: sourceView,
showingCameraView: $viewModel.showingCamera,
resultFile: $viewModel.resultFile,
mainAppModel: viewModel.mainAppModel) : nil
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// AddFileGridItemView.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI

struct AddFileGridItemView: View {

var file: VaultFileDB

@StateObject var viewModel: AddFilesViewModel

var body: some View {
gridItemView
.overlay(deleteButton, alignment: .topTrailing)
}

var gridItemView : some View {
ZStack {
file.gridImage
self.fileNameText
}
}

var deleteButton : some View {
Button {
viewModel.deleteFile(fileId: file.id)
} label: {
Image("delete.cross.icon")
.padding(.all, 10)
}
}

@ViewBuilder
var fileNameText: some View {

if self.file.tellaFileType != .image || self.file.tellaFileType != .video {
VStack {
Spacer()
CustomText(self.file.name,
style: .body3Style)
.lineLimit(1)
Spacer()
.frame(height: 6)
}.padding(EdgeInsets(top: 0, leading: 5, bottom: 0, trailing: 5))
}
}
}

50 changes: 50 additions & 0 deletions Tella/Components/AddFileGridViewComponent/AddFileGridView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// AddFileGridView.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI

struct AddFileGridView: View {

private let gridLayout: [GridItem] = [GridItem(spacing: 12),
GridItem(spacing: 12),
GridItem(spacing: 12)]

private let gridItemHeight = (UIScreen.screenWidth - 64.0) / 3

@ObservedObject var viewModel: AddFilesViewModel

var titleText: String

var body: some View {
VStack(alignment: .leading, spacing: 12) {

attachFilesTextView

itemsGridView

AddFileBottomSheetView(viewModel: viewModel) {
Image("add.file.icon")
}
}
}


var attachFilesTextView: some View {
CustomText(titleText, style: .body1Style)
}

var itemsGridView: some View {
LazyVGrid(columns: gridLayout, alignment: .center, spacing: 12) {
ForEach(viewModel.files.sorted{$0.created < $1.created}, id: \.id) { file in
AddFileGridItemView(file: file, viewModel: viewModel)
.frame(height: gridItemHeight)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// AddFilePhotoVideoPickerView.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI

struct AddFilePhotoVideoPickerView: View {

@ObservedObject var viewModel: AddFilesViewModel

var body: some View {
PhotoVideoPickerView(showingImagePicker: $viewModel.showingImagePicker,
showingImportDocumentPicker: $viewModel.showingImportDocumentPicker,
appModel: viewModel.mainAppModel,
resultFile: $viewModel.resultFile)

}
}
23 changes: 23 additions & 0 deletions Tella/Components/AddFileGridViewComponent/AddFileRecordView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// AddFileRecordView.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI
struct AddFileRecordView: View {

@ObservedObject var viewModel: AddFilesViewModel

var body: some View {
viewModel.showingRecordView ?
RecordView(appModel: viewModel.mainAppModel,
sourceView: .addReportFile,
showingRecoredrView: $viewModel.showingRecordView,
resultFile: $viewModel.resultFile) : nil

}
}
73 changes: 73 additions & 0 deletions Tella/Components/AddFileGridViewComponent/AddFilesViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// AddFilesViewModel.swift
// Tella
//
// Created by RIMA on 26.02.25.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import Foundation
import Combine

class AddFilesViewModel: ObservableObject {

@Published var files: Set <VaultFileDB> = []
@Published var showingImagePicker : Bool = false
@Published var showingImportDocumentPicker : Bool = false
@Published var showingFileList : Bool = false
@Published var showingRecordView : Bool = false
@Published var showingCamera : Bool = false
@Published var resultFile : [VaultFileDB]?
var shouldShowDocumentsOnly: Bool = false

var mainAppModel: MainAppModel
var subscribers = Set<AnyCancellable>()

init(mainAppModel: MainAppModel, shouldShowDocumentsOnly: Bool = false) {
self.mainAppModel = mainAppModel
self.shouldShowDocumentsOnly = shouldShowDocumentsOnly

bindVaultFileTaken()
}
var bottomSheetItems: [ListActionSheetItem] {
var items: [ListActionSheetItem] = []

let basicItems = [
ListActionSheetItem(imageName: "gallery.icon",
content: LocalizableReport.galleryFilled.localized,
type: ManageFileType.tellaFile),
ListActionSheetItem(imageName: "phone.icon",
content: LocalizableReport.phoneFilled.localized,
type: ManageFileType.fromDevice)
]

let secondaryItems = [ListActionSheetItem(imageName: "camera-filled.icon",
content: LocalizableReport.cameraFilled.localized,
type: ManageFileType.camera),
ListActionSheetItem(imageName: "mic-filled.icon",
content: LocalizableReport.micFilled.localized,
type: ManageFileType.recorder)]

if !shouldShowDocumentsOnly {
items = basicItems + secondaryItems
}else {
items = basicItems
}
return items
}


func bindVaultFileTaken() {
$resultFile.sink(receiveValue: { value in
guard let value else { return }
self.files.insert(value)
}).store(in: &subscribers)
}

func deleteFile(fileId: String?) {
guard let index = files.firstIndex(where: { $0.id == fileId}) else {return }
files.remove(at: index)
}
}

49 changes: 49 additions & 0 deletions Tella/Components/BackBottomView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// BackBottomView.swift
// Tella
//
// Created by Dhekra Rouatbi on 23/4/2025.
// Copyright © 2025 HORIZONTAL.
// Licensed under MIT (https://github.com/Horizontal-org/Tella-iOS/blob/develop/LICENSE)
//

import SwiftUI

struct BackBottomView: View {

@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

var backAction : (() -> Void)?

var body: some View {
HStack {
BottomButtonActionView(title: LocalizableLock.actionBack.localized, isValid: true) {
self.backAction?()
self.presentationMode.wrappedValue.dismiss()
}
Spacer()
}
.frame(height: 44)
}

func BottomButtonActionView(title:String,isValid:Bool, action: (() -> Void)?) -> some View {
Button {
UIApplication.shared.endEditing()
action?()
} label: {
Text(title)
}
.style(.link1Style)
.foregroundColor(isValid ? Color.white : Color.gray)
.padding(EdgeInsets(top: 17, leading: 34, bottom: 45, trailing: 34))
.disabled(!isValid)
}

}

#Preview {
BackBottomView()
}



Loading