Skip to content

Commit

Permalink
⚡ Added Example Folder and Fiiles
Browse files Browse the repository at this point in the history
  • Loading branch information
meetAhmed committed May 24, 2024
1 parent 4bcbde4 commit c53623d
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 3 deletions.
62 changes: 62 additions & 0 deletions Example/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// ContentView.swift
// Example
//
// Created by Ahmed Ali on 24/05/2024.
//

import SwiftUI
import RealmSwift
import RealmDebugger

class DatabaseManager {
init() {
do {
let realm = try Realm()

let animalModel1 = AnimalModel()
animalModel1.name = "Dog"

let animalModel2 = AnimalModel()
animalModel2.name = "Cat"

let animalModel3 = AnimalModel()
animalModel3.name = "Horse"

let countryModel1 = CountryModel()
countryModel1.name = "Argentina"
countryModel1.capital = "Buenos Aires"

let countryModel2 = CountryModel()
countryModel2.name = "Brazil"
countryModel2.capital = "Brasília"

let taskModel1 = TaskModel()
taskModel1.name = "Do 30 mins of yoga"

try realm.write {
realm.add(animalModel1)
realm.add(animalModel2)
realm.add(animalModel3)
realm.add(countryModel1)
realm.add(countryModel2)
realm.add(taskModel1)
}
} catch {
print(error)
}
}
}

struct ContentView: View {
private var manager = DatabaseManager()

var body: some View {
VStack {
Text("Hello, world!")
Button("Open Realm Debug View") {
RealmDebugger.presentRealmDebuggerView()
}
}
}
}
13 changes: 13 additions & 0 deletions Example/Data/AnimalModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// AnimalModel.swift
// Example
//
// Created by Ahmed Ali on 24/05/2024.
//

import RealmSwift

class AnimalModel: Object, Identifiable {
@Persisted(primaryKey: true) var id: ObjectId
@Persisted var name: String
}
14 changes: 14 additions & 0 deletions Example/Data/CountryModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// CountryModel.swift
// Example
//
// Created by Ahmed Ali on 24/05/2024.
//

import RealmSwift

class CountryModel: Object, Identifiable {
@Persisted(primaryKey: true) var id: ObjectId
@Persisted var name: String
@Persisted var capital: String
}
13 changes: 13 additions & 0 deletions Example/Data/TaskModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// TaskModel.swift
// Example
//
// Created by Ahmed Ali on 24/05/2024.
//

import RealmSwift

class TaskModel: Object, Identifiable {
@Persisted(primaryKey: true) var id: ObjectId
@Persisted var name: String
}
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "2be6ae78a90ca76841d74ee522cdde6e0b0675395494fbbef38edba3df49a048",
"originHash" : "2fc767ffec5621870671473d6cc30b71caf53cde192fb294d1bbb07ce04dcd04",
"pins" : [
{
"identity" : "realm-core",
Expand Down
2 changes: 1 addition & 1 deletion Sources/RealmDebugger/Views/ListRealmTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct ListRealmTableRowView: View {
.padding()
.background(
RoundedRectangle(cornerRadius: 6)
.fill(Color.gray.opacity(0.3))
.fill(Color.gray.opacity(0.25))
)
.onTapGesture {
RealmDebugger.presentRealmDebuggerViewForTable(tableName: tableName)
Expand Down
2 changes: 1 addition & 1 deletion Sources/RealmDebugger/Views/RealmTableDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct RealmTableDetailRowView: View {
.frame(maxWidth: .infinity, alignment: .leading)
.background(
RoundedRectangle(cornerRadius: 6)
.fill(Color.gray.opacity(0.3))
.fill(Color.gray.opacity(0.25))
)
}
}

0 comments on commit c53623d

Please sign in to comment.