forked from mirrors/linphone-iphone
meetings list - scroll to "Today" on appear and when pressing the top right calendar button
This commit is contained in:
parent
9c949e632d
commit
85be73b84f
3 changed files with 54 additions and 30 deletions
|
|
@ -299,7 +299,18 @@ struct ContentView: View {
|
|||
}
|
||||
.padding(.trailing, index == 2 ? 10 : 0)
|
||||
|
||||
if index != 2 {
|
||||
if index == 3 {
|
||||
Button {
|
||||
NotificationCenter.default.post(name: MeetingsListViewModel.ScrollToTodayNotification, object: nil)
|
||||
} label: {
|
||||
Image("calendar")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
} else if index != 2 {
|
||||
Menu {
|
||||
if index == 0 {
|
||||
Button {
|
||||
|
|
@ -355,7 +366,7 @@ struct ContentView: View {
|
|||
}
|
||||
}
|
||||
} label: {
|
||||
Image(index == 0 ? "funnel" : (index == 3 ? "calendar" : "dots-three-vertical"))
|
||||
Image(index == 0 ? "funnel" : "dots-three-vertical")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(.white)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ struct MeetingsFragment: View {
|
|||
private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom }
|
||||
|
||||
@State var showingSheet: Bool = false
|
||||
@State var reader : ScrollViewProxy?
|
||||
|
||||
@ViewBuilder
|
||||
func createMonthLine(model: MeetingsListItemModel) -> some View {
|
||||
|
|
@ -76,7 +77,6 @@ struct MeetingsFragment: View {
|
|||
.background(.white)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 20))
|
||||
.shadow(color: .black.opacity(0.2), radius: 4)
|
||||
.padding(.bottom, 5)
|
||||
.onTapGesture {
|
||||
withAnimation {
|
||||
if let meetingModel = model.model {
|
||||
|
|
@ -88,15 +88,15 @@ struct MeetingsFragment: View {
|
|||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
ForEach(0..<meetingsListViewModel.meetingsList.count, id: \.self) { index in
|
||||
ScrollViewReader { proxyReader in
|
||||
List(0..<meetingsListViewModel.meetingsList.count, id: \.self) { index in
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
let itemModel = meetingsListViewModel.meetingsList[index]
|
||||
if index == 0 || itemModel.monthStr != meetingsListViewModel.meetingsList[index-1].monthStr {
|
||||
createMonthLine(model: meetingsListViewModel.meetingsList[index])
|
||||
if index == 0 || itemModel.weekStr != meetingsListViewModel.meetingsList[index-1].weekStr {
|
||||
createWeekLine(model: itemModel)
|
||||
}
|
||||
}
|
||||
if index == 0 || itemModel.weekStr != meetingsListViewModel.meetingsList[index-1].weekStr {
|
||||
createWeekLine(model: itemModel)
|
||||
}
|
||||
|
||||
if index == 0
|
||||
|
|
@ -129,35 +129,47 @@ struct MeetingsFragment: View {
|
|||
} else {
|
||||
createMeetingLine(model: itemModel)
|
||||
}
|
||||
}.padding(.top, 10)
|
||||
}
|
||||
} else {
|
||||
createMeetingLine(model: itemModel)
|
||||
.padding(.leading, 40)
|
||||
.padding(.leading, 45)
|
||||
}
|
||||
}
|
||||
.id(index)
|
||||
.listRowInsets(.init(top: 5, leading: 10, bottom: 5, trailing: 15))
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.overlay(
|
||||
VStack {
|
||||
if meetingsListViewModel.meetingsList.isEmpty {
|
||||
Spacer()
|
||||
Image("illus-belledonne")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.clipped()
|
||||
.padding(.all)
|
||||
Text("No meeting for the moment...")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
Spacer()
|
||||
Spacer()
|
||||
.onAppear {
|
||||
proxyReader.scrollTo(meetingsListViewModel.todayIdx)
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: MeetingsListViewModel.ScrollToTodayNotification)) { _ in
|
||||
withAnimation {
|
||||
Log.info("debugtrace - List ScrollToTodayNotification")
|
||||
proxyReader.scrollTo(meetingsListViewModel.todayIdx)
|
||||
}
|
||||
}
|
||||
.padding(.all)
|
||||
)
|
||||
.listStyle(.plain)
|
||||
.overlay(
|
||||
VStack {
|
||||
if meetingsListViewModel.meetingsList.isEmpty {
|
||||
Spacer()
|
||||
Image("illus-belledonne")
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.clipped()
|
||||
.padding(.all)
|
||||
Text("No meeting for the moment...")
|
||||
.default_text_style_800(styleSize: 16)
|
||||
Spacer()
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.padding(.all)
|
||||
)
|
||||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import Combine
|
|||
|
||||
class MeetingsListViewModel: ObservableObject {
|
||||
static let TAG = "[Meetings ListViewModel]"
|
||||
static let ScrollToTodayNotification = Notification.Name("ScrollToToday")
|
||||
|
||||
private var coreContext = CoreContext.shared
|
||||
private var mCoreSuscriptions = Set<AnyCancellable?>()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue