Skip to content
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

New footer section #340

Merged
merged 7 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 35 additions & 1 deletion KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.Buttons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ extension WidgetLibrary.UI {
struct Minimize: View {
@EnvironmentObject public var state: Navigation
public var onAction: (() -> Void)? = {}
public var font: Font = .title2
@Binding public var isMinimized: Bool
@State private var isHighlighted: Bool = false

Expand All @@ -305,7 +306,7 @@ extension WidgetLibrary.UI {
showLabel: false,
size: .tiny,
type: .clear,
font: .title2
font: self.font
)
.padding([.top, .bottom], 10)
.help("Create a new record")
Expand Down Expand Up @@ -559,6 +560,39 @@ extension WidgetLibrary.UI {
.useDefaultHover({ hover in self.isHighlighted = hover})
}
}

// MARK: Buttons.FooterActivity
struct FooterActivity: View {
@EnvironmentObject private var state: Navigation
var count: Int
var label: String
var icon: String
@AppStorage("widgetlibrary.ui.appfooter.isMinimized") private var isMinimized: Bool = false
@State private var isHighlighted: Bool = false

var body: some View {
Button {
self.isMinimized.toggle()
} label: {
HStack(spacing: 0) {
Image(systemName: self.icon)
.foregroundStyle(.white)
.padding(8)
Text("\(self.count) \(self.label)")
.bold(self.count > 0)
.padding(8)
.background(Theme.lightWhite)
.foregroundStyle(Theme.base)
.underline(self.isHighlighted)
}
.background(Theme.cPurple)
.clipShape(.capsule(style: .circular))
}
.buttonStyle(.plain)
.useDefaultHover({ hover in self.isHighlighted = hover })
.help("\(self.count) \(self.label) on \(self.state.session.dateFormatted("MMMM dd, yyyy"))")
}
}
}
}

Expand Down
106 changes: 80 additions & 26 deletions KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,51 @@ extension WidgetLibrary {
}
}

struct AppFooter: View {
@EnvironmentObject private var state: Navigation
@AppStorage("widgetlibrary.ui.appfooter.isMinimized") private var isMinimized: Bool = false
private var twoCol: [GridItem] { Array(repeating: .init(.flexible(minimum: 100)), count: 2) }

var body: some View {
VStack(alignment: .leading, spacing: 0) {
Divider()
ZStack(alignment: .topTrailing) {
if !self.isMinimized {
LinearGradient(colors: [Theme.base, .clear], startPoint: .top, endPoint: .bottom)
.blendMode(.softLight)
} else {
Theme.base.blendMode(.softLight)
}
LazyVGrid(columns: self.twoCol, alignment: .leading, spacing: 10) {
GridRow {
UI.SuggestedLinksInRange(
period: .day,
start: self.state.session.date.startOfDay,
end: self.state.session.date.endOfDay,
format: "MMMM dd",
useMiniMode: self.isMinimized
)
UI.InteractionsInRange(
period: .day,
start: self.state.session.date.startOfDay,
end: self.state.session.date.endOfDay,
format: "MMMM dd",
useMiniMode: self.isMinimized
)
}
}
.padding()
HStack {
Spacer()
UI.Buttons.Minimize(font: .title, isMinimized: $isMinimized)
.padding([.trailing, .top], 16)
}
}
}
.frame(height: self.isMinimized ? 60 : 270)
}
}

struct SimpleDateSelector: View {
@EnvironmentObject private var state: Navigation
@AppStorage("today.numPastDates") public var numPastDates: Int = 20
Expand Down Expand Up @@ -384,10 +429,10 @@ extension WidgetLibrary {
HStack(alignment: .center) {
if let image = self.iconAsImage {
image
.foregroundStyle(self.state.session.job?.backgroundColor ?? .yellow)
.foregroundStyle(self.state.theme.tint)
} else if let icon = self.icon {
Image(systemName: icon)
.foregroundStyle(self.state.session.job?.backgroundColor ?? .yellow)
.foregroundStyle(self.state.theme.tint)
}
Text(self.name)
Spacer()
Expand Down Expand Up @@ -898,7 +943,7 @@ extension WidgetLibrary {
standalone: true,
location: .content,
mode: .compact,
page: .explore,
page: self.state.session.appPage,
alwaysShowTab: true
)
Spacer()
Expand All @@ -921,22 +966,29 @@ extension WidgetLibrary {
public var start: Date?
public var end: Date?
public var format: String?
public var useMiniMode: Bool = false
@State private var activities: [Activity] = []
@State private var tabs: [ToolbarButton] = []
@State private var vid: UUID = UUID()

var body: some View {
VStack {
UI.ListLinkTitle(text: "Suggested links from \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))")
UI.ActivityLinks(activities: self.activities)
Spacer()
if !self.useMiniMode {
UI.ListLinkTitle(text: "Suggested links from \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))")
UI.ActivityLinks(activities: self.activities)
} else {
UI.Buttons.FooterActivity(count: self.activities.count, label: "Links", icon: "link")
}
}
.id(self.vid)
.onAppear(perform: self.actionOnAppear)
.onChange(of: self.state.session.date) { self.actionOnAppear() }
.onChange(of: self.state.session.timeline.date) { self.actionOnAppear() }
.onChange(of: self.start) { self.actionOnAppear() }
.onChange(of: self.end) { self.actionOnAppear() }
.onChange(of: self.state.saved) {
if self.state.saved {
self.actionOnAppear()
}
}
}
}

Expand Down Expand Up @@ -1008,26 +1060,28 @@ extension WidgetLibrary {
public var start: Date?
public var end: Date?
public var format: String?
@State private var activities: [Activity] = []
public var useMiniMode: Bool = false
@State private var tabs: [ToolbarButton] = []
@State private var vid: UUID = UUID()

var body: some View {
VStack {
UI.ListLinkTitle(text: "Interactions from \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))")
FancyGenericToolbar(
buttons: self.tabs,
standalone: true,
location: .content,
mode: .compact,
page: .explore,
alwaysShowTab: true
)
if !self.useMiniMode {
UI.ListLinkTitle(text: "Interactions from \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))")
FancyGenericToolbar(
buttons: self.tabs,
standalone: true,
location: .content,
mode: .compact,
page: self.state.session.appPage,
alwaysShowTab: true
)
}
Spacer()
}
.id(self.vid)
.onAppear(perform: self.actionOnAppear)
.onChange(of: self.state.session.date) { self.vid = UUID() }
.onChange(of: self.state.session.date) { self.vid = UUID() ; self.actionOnAppear() }
.onChange(of: self.state.session.timeline.date) { self.vid = UUID() ; self.actionOnAppear() }
.onChange(of: self.state.session.timeline.custom.rangeStart) { self.vid = UUID() ; self.actionOnAppear() }
.onChange(of: self.state.session.timeline.custom.rangeEnd) { self.vid = UUID() ; self.actionOnAppear() }
Expand All @@ -1052,7 +1106,7 @@ extension WidgetLibrary {
standalone: true,
location: .content,
mode: .full,
page: .explore
page: self.state.session.appPage
)
Spacer()
}
Expand Down Expand Up @@ -2125,23 +2179,23 @@ extension WidgetLibrary.UI.InteractionsInRange {
self.tabs.append(
ToolbarButton(
id: 0,
helpText: "Jobs interacted with in \(self.format == nil ? "period" : self.state.session.timeline.formatted(self.format!))",
helpText: "Jobs interacted with in \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))",
icon: "hammer",
labelText: "Jobs",
contents: AnyView(
UI.SimpleEntityList(type: .jobs, start: self.state.session.timeline.custom.rangeStart, end: self.state.session.timeline.custom.rangeEnd)
UI.SimpleEntityList(type: .jobs, start: self.start, end: self.end)
)
)
)
if self.showProjects {
self.tabs.append(
ToolbarButton(
id: 1,
helpText: "Projects interacted with in \(self.format == nil ? "period" : self.state.session.timeline.formatted(self.format!))",
helpText: "Projects interacted with in \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))",
icon: "folder",
labelText: "Projects",
contents: AnyView(
UI.SimpleEntityList(type: .projects, start: self.state.session.timeline.custom.rangeStart, end: self.state.session.timeline.custom.rangeEnd)
UI.SimpleEntityList(type: .projects, start: self.start, end: self.end)
)
)
)
Expand All @@ -2150,11 +2204,11 @@ extension WidgetLibrary.UI.InteractionsInRange {
self.tabs.append(
ToolbarButton(
id: 2,
helpText: "Companies interacted with in \(self.format == nil ? "period" : self.state.session.timeline.formatted(self.format!))",
helpText: "Companies interacted with in \(self.format == nil ? "period" : self.state.session.dateFormatted(self.format!))",
icon: "building.2",
labelText: "Companies",
contents: AnyView(
UI.SimpleEntityList(type: .companies, start: self.state.session.timeline.custom.rangeStart, end: self.state.session.timeline.custom.rangeEnd)
UI.SimpleEntityList(type: .companies, start: self.start, end: self.end)
)
)
)
Expand Down
50 changes: 23 additions & 27 deletions KlockWork/Views/Entities/Today/LogTable/LogTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Today {
standalone: true,
location: .content,
mode: .compact,
page: .today
page: self.nav.session.appPage
)
}
}
Expand Down Expand Up @@ -100,13 +100,11 @@ extension Today.LogTable {
@EnvironmentObject public var nav: Navigation

var body: some View {
ScrollView(showsIndicators: false) {
VStack(spacing: 1) {
if records.count > 0 {
FancyTextField(placeholder: "Records...", lineLimit: 10, text: $plain)
} else {
LogRowEmpty(message: "No records found for date \(nav.session.date.formatted(date: .abbreviated, time: .omitted))", index: 0, colour: Theme.rowColour)
}
VStack(spacing: 1) {
if records.count > 0 {
FancyTextField(placeholder: "Records...", lineLimit: 10, text: $plain)
} else {
LogRowEmpty(message: "No records found for date \(nav.session.date.formatted(date: .abbreviated, time: .omitted))", index: 0, colour: Theme.rowColour)
}
}
.onAppear(perform: actionOnAppear)
Expand All @@ -124,28 +122,26 @@ extension Today.LogTable {
@State private var offset: Int = 0

var body: some View {
ScrollView(showsIndicators: false) {
VStack(spacing: 0) {
if records.count > 0 {
ForEach(self.records, id: \.objectID) { record in
if record.job != nil {
let entry = Entry(
timestamp: DateHelper.longDate(record.timestamp!),
job: record.job!,
message: record.message!
)
VStack(spacing: 0) {
if records.count > 0 {
ForEach(self.records, id: \.objectID) { record in
if record.job != nil {
let entry = Entry(
timestamp: DateHelper.longDate(record.timestamp!),
job: record.job!,
message: record.message!
)

LogRow(
entry: entry,
index: records.firstIndex(of: record),
colour: record.job?.backgroundColor ?? Theme.rowColour,
record: record
)
}
LogRow(
entry: entry,
index: records.firstIndex(of: record),
colour: record.job?.backgroundColor ?? Theme.rowColour,
record: record
)
}
} else {
LogRowEmpty(message: "No records found for \(nav.session.date.formatted(date: .abbreviated, time: .omitted))", index: 0, colour: Theme.rowColour)
}
} else {
LogRowEmpty(message: "No records found for \(nav.session.date.formatted(date: .abbreviated, time: .omitted))", index: 0, colour: Theme.rowColour)
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions KlockWork/Views/Entities/Today/Today.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import KWCore
struct Today: View {
public var defaultSelectedDate: Date? = nil
private let page: PageConfiguration.AppPage = .today
private var twoCol: [GridItem] { Array(repeating: .init(.flexible(minimum: 100)), count: 2) }

@AppStorage("today.commandLineMode") private var commandLineMode: Bool = false

Expand All @@ -22,10 +23,13 @@ struct Today: View {
CommandLineInterface()
} else {
VStack(alignment: .leading, spacing: 0) {
PostingInterface()
LogTable()
VStack(alignment: .leading, spacing: 0) {
PostingInterface()
LogTable()
}
.padding()
UI.AppFooter()
}
.padding()
}
}
.background(Theme.toolbarColour)
Expand Down
7 changes: 3 additions & 4 deletions KlockWork/Views/Shared/Fancy/FancyGenericToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ struct FancyGenericToolbar: View {
}
.padding(standalone ? 0 : 20)
}

}
}
}
Expand Down Expand Up @@ -208,7 +207,7 @@ struct FancyGenericToolbar: View {
if self.button.showIcon {
button.icon
.padding(0)
.foregroundStyle(self.selected == self.button.id ? self.nav.session.job?.backgroundColor ?? .white : .white.opacity(0.5))
.foregroundStyle(self.selected == self.button.id ? .white : .white.opacity(0.5))
}
} else {
if self.showTabTitles && self.button.showLabel {
Expand All @@ -222,7 +221,7 @@ struct FancyGenericToolbar: View {
HStack(alignment: .center, spacing: 8) {
if self.button.showIcon {
self.button.icon
.foregroundStyle(self.selected == self.button.id ? self.nav.session.job?.backgroundColor ?? .white : .white.opacity(0.5))
.foregroundStyle(self.selected == self.button.id ? .white : .white.opacity(0.5))
.font(.title3)
}

Expand All @@ -241,7 +240,7 @@ struct FancyGenericToolbar: View {
} else {
if self.button.showIcon {
self.button.icon
.foregroundStyle(self.selected == self.button.id ? self.nav.session.job?.backgroundColor ?? .white : .white.opacity(0.5))
.foregroundStyle(self.selected == self.button.id ? .white : .white.opacity(0.5))
.font(.title3)
.padding([.top, .bottom], 10)
.padding([.leading, .trailing])
Expand Down