Skip to content

Commit

Permalink
0.1.6 Announcements, and log out button
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectricS01 committed Mar 3, 2024
1 parent a1a51d2 commit c5b30ac
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 44 deletions.
4 changes: 2 additions & 2 deletions TPU Mac/TPU_Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.1.5;
MARKETING_VERSION = 0.1.6;
PRODUCT_BUNDLE_IDENTIFIER = "ElectricS01.TPU-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down Expand Up @@ -542,7 +542,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.1.5;
MARKETING_VERSION = 0.1.6;
PRODUCT_BUNDLE_IDENTIFIER = "ElectricS01.TPU-Mac";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
38 changes: 19 additions & 19 deletions TPU Mac/TPU_Mac/CommsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ struct CommsView: View {
ForEach(0 ..< chatsList.count, id: \.self) { result in
Button(action: { getChat(chatId: result) }) {
HStack {
ProfilePicture(avatar: (chatsList[result].recipient?.avatar ?? chatsList[result].icon))
Text(chatsList[result].recipient?.username ?? chatsList[result].name)
.lineLimit(1)
ProfilePicture(avatar: chatsList[result].recipient?.avatar ?? chatsList[result].icon)
Text(chatsList[result].recipient?.username ?? chatsList[result].name).lineLimit(1)
Spacer()
if chatsList[result].unread != 0 {
Text(String(chatsList[result].unread!))
Expand All @@ -319,11 +318,9 @@ struct CommsView: View {
.cornerRadius(10)
}
}.contentShape(Rectangle())
}
.buttonStyle(.plain)
}.buttonStyle(.plain)
}
}
.frame(width: 150)
.padding(EdgeInsets(top: -8, leading: -10, bottom: -8, trailing: 0))
if chatOpen != -1 {
ScrollViewReader { proxy in
Expand Down Expand Up @@ -386,18 +383,20 @@ struct CommsView: View {
if embed.media != [] {
LazyImage(url: URL(string: embed.media?[0].attachment == nil ? ("https://i.electrics01.com" + (embed.media?[0].proxyUrl ?? "")) : ("https://i.electrics01.com/i/" + (embed.media?[0].attachment ?? "")))) { state in
if let image = state.image {
image.resizable().aspectRatio(contentMode: .fill)
image
.resizable()
.aspectRatio(contentMode: .fill)
.onAppear {
if chatMessages.count != 0 {
proxy.scrollTo(0, anchor: .bottom)
}
}
} else if state.error != nil {
Color.red
} else {
ProgressView()
}
}.frame(minWidth: 0, maxWidth: 400, minHeight: 0, maxHeight: 400)
.onAppear {
if chatMessages.count != 0 {
proxy.scrollTo(chatMessages.last?.id)
}
}
}
}.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: .topLeading)
}
Expand All @@ -418,13 +417,14 @@ struct CommsView: View {
Image(systemName: "pencil").frame(width: 16, height: 16)
}
}.padding(4)
.id(message.id)
// .background(Color(hoverItem == message.id ? Color.primary : .clear))
// .onHover(perform: { _ in
// hoverItem = message.id
// })
}.padding(EdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 12))
}.frame(
}
.id(0)
.frame(
minWidth: 0,
maxWidth: .infinity,
minHeight: 0,
Expand All @@ -433,11 +433,11 @@ struct CommsView: View {
)
.onAppear {
if chatMessages.count != 0 {
proxy.scrollTo(chatMessages.last?.id)
proxy.scrollTo(0, anchor: .bottom)
}
}
.onChange(of: chatMessages) {
proxy.scrollTo(chatMessages.last?.id)
proxy.scrollTo(0, anchor: .bottom)
}
}
if replyingId != -1 {
Expand All @@ -449,7 +449,7 @@ struct CommsView: View {
.lineLimit(1)
.onAppear {
if chatMessages.count != 0 {
proxy.scrollTo(chatMessages.last?.id)
proxy.scrollTo(0, anchor: .bottom)
}
}
}.padding(EdgeInsets(top: 0, leading: 18, bottom: 0, trailing: 0))
Expand All @@ -474,8 +474,8 @@ struct CommsView: View {
}.contentShape(Rectangle())
}.buttonStyle(.plain)
}
}.frame(width: 150)
.padding(EdgeInsets(top: -8, leading: -10, bottom: -8, trailing: 0))
}
.padding(EdgeInsets(top: -8, leading: -10, bottom: -8, trailing: 0))
} else {
VStack {
Spacer()
Expand Down
28 changes: 17 additions & 11 deletions TPU Mac/TPU_Mac/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ struct ContentView: View {
var body: some View {
NavigationSplitView {
List {
NavigationLink(destination: HomeView(showingLogin: $showingLogin, coreState: $coreState)
.sheet(isPresented: $showingLogin) {
LoginSheet()
}) {
Label("Home", systemImage: "house")
}
NavigationLink(destination: SettingsView(coreState: $coreState)) {
NavigationLink(destination: HomeView(coreState: $coreState)) {
Label("Home", systemImage: "house")
}
NavigationLink(destination: SettingsView(showingLogin: $showingLogin, coreState: $coreState)) {
Label("Settings", systemImage: "gear")
}
NavigationLink(destination: GalleryView(stars: .constant(false))) {
Expand All @@ -73,11 +70,14 @@ struct ContentView: View {
}
}
} detail: {
HomeView(showingLogin: $showingLogin, coreState: $coreState)
HomeView(coreState: $coreState)
.sheet(isPresented: $showingLogin) {
LoginSheet()
}
}
.sheet(isPresented: $showingLogin) {
LoginSheet()
}
}
}

Expand Down Expand Up @@ -148,15 +148,21 @@ struct LoginSheet: View {
.lineLimit(4)
.fixedSize(horizontal: false, vertical: true)
}.padding()
.interactiveDismissDisabled()
}
}

struct SettingsView: View {
@Binding var showingLogin: Bool
@Binding var coreState: StateQuery.Data.CoreState?

var body: some View {
Text("Settings")
Text("Coming soon")
.navigationTitle("Settings")
Button("Log out") {
keychain.delete("token")
}
}
}

Expand All @@ -165,11 +171,11 @@ struct AboutView: View {
Text("About")
.navigationTitle("About")
#if os(macOS)
Text("TPU Mac").font(.system(size: 24, weight: .semibold))
Text("TPU Mac").font(.system(size: 32, weight: .semibold))
#else
Text("TPU iOS").font(.system(size: 24, weight: .semibold))
Text("TPU iOS").font(.system(size: 32, weight: .semibold))
#endif
Text("Version " + (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") + " (2/3/2024)")
Text("Version " + (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "") + " (3/3/2024)")
Text("Made by ElectricS01")
Text("[Give it a Star on GitHub](https://github.com/ElectricS01/TPU-Mac)")
}
Expand Down
38 changes: 26 additions & 12 deletions TPU Mac/TPU_Mac/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,36 @@ struct HomeStat: View {
}

struct HomeView: View {
@Binding var showingLogin: Bool
@Binding var coreState: StateQuery.Data.CoreState?

var body: some View {
HStack {
VStack {
Text("Welcome to")
#if os(macOS)
Text("TPU Mac").font(.system(size: 32, weight: .semibold))
#else
Text("TPU iOS").font(.system(size: 32, weight: .semibold))
#endif
Button("Backup Login") {
showingLogin = true
}
.navigationTitle("Home")
VStack {
Text("Welcome to")
.navigationTitle("Home")
#if os(macOS)
Text("TPU Mac").font(.system(size: 32, weight: .semibold))
#else
Text("TPU iOS").font(.system(size: 32, weight: .semibold))
#endif
}.frame(maxHeight: .infinity)
VStack {
Text("Announcments").font(.system(size: 24, weight: .semibold))
ScrollView {
ForEach(coreState?.announcements ?? [], id: \.self) { item in
ProfilePicture(avatar: item.user.avatar, size: 48)
Text(item.user.username).font(.system(size: 16, weight: .semibold))
Text(item.content).multilineTextAlignment(.center)
if let date = inputDateFormatter.date(from: item.createdAt ?? "") {
let formattedDate = outputDateFormatter.string(from: date)
Text(formattedDate)
} else {
Text("Invalid Date")
}
}.padding()
}
}.frame(maxHeight: .infinity)
}
.frame(maxWidth: .infinity)
LazyVGrid(columns: [GridItem(.adaptive(minimum: 150))], spacing: 10) {
Expand All @@ -48,7 +62,7 @@ struct HomeView: View {
HomeStat(stat: .constant(String(coreState?.stats.users ?? 0)), type: .constant("Users"))
HomeStat(stat: .constant(String(coreState?.stats.uploads ?? 0)), type: .constant("Uploads"))
HomeStat(stat: .constant(String(coreState?.stats.chats ?? 0)), type: .constant("Chats"))
HomeStat(stat: .constant(String(coreState?.stats.messages ?? 0)), type: .constant("Chats"))
HomeStat(stat: .constant(String(coreState?.stats.messages ?? 0)), type: .constant("Chat Messages"))
}
.padding(20)
.frame(maxWidth: .infinity)
Expand Down

0 comments on commit c5b30ac

Please sign in to comment.