mirror of
https://github.com/neon443/NearFuture.git
synced 2026-03-11 06:49:12 +00:00
tring to ad animations
This commit is contained in:
@@ -126,6 +126,7 @@ struct EventListView: View {
|
||||
)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.transition(.opacity)
|
||||
.contextMenu() {
|
||||
Button(role: .destructive) {
|
||||
let eventToModify = viewModel.events.firstIndex() { currEvent in
|
||||
|
||||
@@ -20,7 +20,7 @@ import UserNotifications
|
||||
// }
|
||||
//}
|
||||
|
||||
struct Event: Identifiable, Codable {
|
||||
struct Event: Identifiable, Codable, Equatable {
|
||||
var id = UUID()
|
||||
var name: String
|
||||
var complete: Bool
|
||||
@@ -415,9 +415,20 @@ class EventViewModel: ObservableObject {
|
||||
}
|
||||
|
||||
class dummyEventViewModel: EventViewModel {
|
||||
var template2: Event
|
||||
override init(load: Bool = false) {
|
||||
self.template2 = Event(
|
||||
name: "template2",
|
||||
complete: false,
|
||||
completeDesc: "",
|
||||
symbol: "hammer",
|
||||
color: ColorCodable(randomColor()),
|
||||
notes: "notes",
|
||||
date: Date(),
|
||||
recurrence: .none
|
||||
)
|
||||
super.init(load: false)
|
||||
self.events = [self.example, self.template, self.example, self.template]
|
||||
self.events = [self.example, self.template, self.template2]
|
||||
self.events[0].complete.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ struct ArchiveView: View {
|
||||
ForEach(viewModel.events.filter({$0.complete})) { event in
|
||||
EventListView(viewModel: viewModel, event: event)
|
||||
}
|
||||
}
|
||||
.transition(.opacity)
|
||||
.padding(.horizontal)
|
||||
.id(hey)
|
||||
.onReceive(viewModel.objectWillChange) {
|
||||
@@ -29,7 +31,6 @@ struct ArchiveView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .topBarTrailing) {
|
||||
|
||||
@@ -24,6 +24,8 @@ struct AddEventView: View {
|
||||
@State var showNeedsNameAlert: Bool = false
|
||||
@State var isSymbolPickerPresented = false
|
||||
|
||||
@State private var bye: Bool = false
|
||||
|
||||
@FocusState private var focusedField: Field?
|
||||
private enum Field {
|
||||
case Name, Notes
|
||||
@@ -32,6 +34,8 @@ struct AddEventView: View {
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
backgroundGradient
|
||||
NavigationStack {
|
||||
Form {
|
||||
Section(
|
||||
@@ -168,6 +172,7 @@ struct AddEventView: View {
|
||||
recurrence: eventRecurrence
|
||||
)
|
||||
)
|
||||
bye.toggle()
|
||||
resetAddEventView()
|
||||
} label: {
|
||||
Text("Save")
|
||||
@@ -175,6 +180,11 @@ struct AddEventView: View {
|
||||
.cornerRadius(10)
|
||||
.buttonStyle(BorderedProminentButtonStyle())
|
||||
}
|
||||
.apply {
|
||||
if #available(iOS 17, *) {
|
||||
$0.sensoryFeedback(.success, trigger: bye)
|
||||
}
|
||||
}
|
||||
.disabled(eventName.isEmpty)
|
||||
.onTapGesture {
|
||||
if eventName.isEmpty {
|
||||
@@ -201,6 +211,7 @@ struct AddEventView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func resetAddEventView() {
|
||||
//reset addeventView
|
||||
eventName = viewModel.template.name
|
||||
|
||||
@@ -13,11 +13,16 @@ enum Field {
|
||||
case Search
|
||||
}
|
||||
enum Tab {
|
||||
case Home
|
||||
case Archive
|
||||
case Statistics
|
||||
case Settings
|
||||
case Gradient
|
||||
case home
|
||||
case archive
|
||||
case stats
|
||||
case settings
|
||||
}
|
||||
enum FilterCategory {
|
||||
case Future
|
||||
case Past
|
||||
case Complete
|
||||
case Incomplete
|
||||
}
|
||||
|
||||
struct ContentView: View {
|
||||
@@ -36,7 +41,11 @@ struct ContentView: View {
|
||||
@State private var searchInput: String = ""
|
||||
var filteredEvents: [Event] {
|
||||
if searchInput.isEmpty {
|
||||
if settingsModel.settings.showCompletedInHome {
|
||||
return viewModel.events
|
||||
} else {
|
||||
return viewModel.events.filter() {!$0.complete}
|
||||
}
|
||||
} else {
|
||||
return viewModel.events.filter {
|
||||
$0.name.localizedCaseInsensitiveContains(searchInput) ||
|
||||
@@ -44,17 +53,9 @@ struct ContentView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var noEvents: Bool {
|
||||
if viewModel.events.count == 0 {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@State private var focusedTab: Tab = .home
|
||||
|
||||
@FocusState private var focusedField: Field?
|
||||
@FocusState private var focusedTab: Tab?
|
||||
|
||||
var body: some View {
|
||||
TabView {
|
||||
@@ -85,17 +86,28 @@ struct ContentView: View {
|
||||
if filteredEvents.isEmpty && !searchInput.isEmpty {
|
||||
HelpView(searchInput: $searchInput, focusedField: focusedField)
|
||||
} else {
|
||||
Button("hiiiiiiiiiiiiiii") {
|
||||
withAnimation() {
|
||||
settingsModel.settings.showCompletedInHome.toggle()
|
||||
}
|
||||
}
|
||||
Button("sort") {
|
||||
withAnimation() {
|
||||
viewModel.events.sort() { $0.date < $1.date }
|
||||
}
|
||||
}
|
||||
ScrollView {
|
||||
ForEach(filteredEvents) { event in
|
||||
EventListView(viewModel: viewModel, event: event)
|
||||
}
|
||||
.onDelete(perform: viewModel.removeEvent)
|
||||
.animation(.default, value: filteredEvents)
|
||||
.transition(.opacity)
|
||||
.id(hey)
|
||||
.onReceive(viewModel.objectWillChange) {
|
||||
hey = UUID()
|
||||
}
|
||||
.padding(.horizontal)
|
||||
if /*!searchInput.isEmpty && */filteredEvents.isEmpty {
|
||||
if filteredEvents.isEmpty {
|
||||
HelpView(
|
||||
searchInput: $searchInput,
|
||||
focusedField: focusedField
|
||||
@@ -143,22 +155,22 @@ struct ContentView: View {
|
||||
.tabItem {
|
||||
Label("Home", systemImage: "house")
|
||||
}
|
||||
.focused($focusedTab, equals: Tab.Home)
|
||||
.tag(Tab.home)
|
||||
ArchiveView(viewModel: viewModel)
|
||||
.tabItem() {
|
||||
Label("Archive", systemImage: "tray.full")
|
||||
}
|
||||
.focused($focusedTab, equals: Tab.Archive)
|
||||
.tag(Tab.archive)
|
||||
StatsView(viewModel: viewModel)
|
||||
.tabItem {
|
||||
Label("Statistics", systemImage: "chart.pie")
|
||||
}
|
||||
.focused($focusedTab, equals: Tab.Statistics)
|
||||
.tag(Tab.stats)
|
||||
SettingsView(viewModel: viewModel, settingsModel: settingsModel)
|
||||
.tabItem {
|
||||
Label("Settings", systemImage: "gear")
|
||||
}
|
||||
.focused($focusedTab, equals: Tab.Settings)
|
||||
.tag(Tab.settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ struct EventListView: View {
|
||||
VStack {
|
||||
Text("\(daysUntilEvent(event.date).long)")
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.one)
|
||||
.foregroundStyle(event.date.timeIntervalSinceNow < 0 ? .red : .one)
|
||||
}
|
||||
Button() {
|
||||
withAnimation {
|
||||
@@ -112,6 +112,7 @@ struct EventListView: View {
|
||||
.shadow(radius: 5)
|
||||
.padding(.trailing, 5)
|
||||
}
|
||||
.transition(.opacity)
|
||||
.padding(.vertical, 5)
|
||||
.background(.ultraThinMaterial)
|
||||
.overlay(
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user