Skip to content

Commit

Permalink
第4节
Browse files Browse the repository at this point in the history
创建历史记录视图
接下来,您将构建Scrumdinger的最后一个视图。您已使用语音识别器转录会议。现在,您将创建一个历史视图,以显示会议文本和与会者。
  • Loading branch information
mona-lisa-octo-ue5 committed Jan 6, 2021
1 parent 8501127 commit 87bc990
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
4 changes: 4 additions & 0 deletions SwiftUIPro/SwiftUIPro.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
64F0C3E425A588D7008BE9EA /* MeetingFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64F0C3E325A588D7008BE9EA /* MeetingFooterView.swift */; };
64F0C3E725A590DA008BE9EA /* ScrumProgressViewStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64F0C3E625A590DA008BE9EA /* ScrumProgressViewStyle.swift */; };
64F0C3EB25A59F1F008BE9EA /* MeetingTimerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64F0C3EA25A59F1F008BE9EA /* MeetingTimerView.swift */; };
64F0C3EE25A5ABF9008BE9EA /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64F0C3ED25A5ABF9008BE9EA /* HistoryView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -52,6 +53,7 @@
64F0C3E325A588D7008BE9EA /* MeetingFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingFooterView.swift; sourceTree = "<group>"; };
64F0C3E625A590DA008BE9EA /* ScrumProgressViewStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrumProgressViewStyle.swift; sourceTree = "<group>"; };
64F0C3EA25A59F1F008BE9EA /* MeetingTimerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeetingTimerView.swift; sourceTree = "<group>"; };
64F0C3ED25A5ABF9008BE9EA /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -96,6 +98,7 @@
64F0C3E325A588D7008BE9EA /* MeetingFooterView.swift */,
64F0C3E625A590DA008BE9EA /* ScrumProgressViewStyle.swift */,
64F0C3EA25A59F1F008BE9EA /* MeetingTimerView.swift */,
64F0C3ED25A5ABF9008BE9EA /* HistoryView.swift */,
6458AF2225A445140063BFE0 /* Assets.xcassets */,
6458AF2725A445140063BFE0 /* Info.plist */,
6458AF2425A445140063BFE0 /* Preview Content */,
Expand Down Expand Up @@ -206,6 +209,7 @@
64F0C3BB25A44BEA008BE9EA /* Color+Codable.swift in Sources */,
64F0C3CE25A45D5D008BE9EA /* SpeechRecognizer.swift in Sources */,
64F0C3DA25A47428008BE9EA /* DetailView.swift in Sources */,
64F0C3EE25A5ABF9008BE9EA /* HistoryView.swift in Sources */,
64F0C3E125A566C9008BE9EA /* MeetingHeaderView.swift in Sources */,
64F0C3D725A46F91008BE9EA /* ScrumsView.swift in Sources */,
6458AF1F25A445120063BFE0 /* SwiftUIProApp.swift in Sources */,
Expand Down
Binary file not shown.
41 changes: 41 additions & 0 deletions SwiftUIPro/SwiftUIPro/HistoryView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// HistoryView.swift
// SwiftUIPro
//
// Created by 石玉龙 on 2021/1/6.
//

import SwiftUI

struct HistoryView: View {
let history:History
var body: some View {
ScrollView{
VStack(alignment:.leading){
Divider()
.padding(.bottom)
Text("Attendees")
.font(.headline)
Text(history.attendeeString)
if let transcript=history.transcript{
Text("Transcript")
.font(.headline)
.padding(.top)
Text(transcript)
}
}
}
.navigationTitle(Text(history.date,style: .date))
.padding()
}
}
extension History{
var attendeeString:String{
ListFormatter.localizedString(byJoining: attendees)
}
}
struct HistoryView_Previews: PreviewProvider {
static var previews: some View {
HistoryView(history: History(attendees: ["Jon", "Darla", "Luis"], lengthInMinutes: 10, transcript:"Darla, would you like to start today? Sure, yesterday I reviewed Luis' PR and met with the design team to finalize the UI..."))
}
}
1 change: 0 additions & 1 deletion SwiftUIPro/SwiftUIPro/MeetingFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import SwiftUI

struct MeetingFooterView: View {
@Binding var speakers:[ScrumTimer.Speaker]
//¥¨ˆøøπ“‘«æ…¬˚∆˙©ƒ∂ßßåΩ≈Ç√ı√√√√√√ı˜√ı˜Â≤≥÷∞¢¡™£¢∞§¶•ªº–≠≠≠≠≠–≠≠––ºª
var skipAction:()->Void
private var speakerNumber:Int?{
guard let index = speakers.firstIndex(where: {!$0.isCompleted}) else { return nil }
Expand Down
2 changes: 1 addition & 1 deletion SwiftUIPro/SwiftUIPro/MeetingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct MeetingView: View {
scrumTimer.stopScrum()
speechRecognizer.stopRecording()
isRecording=false
let newHistory=History(attendees: scrum.attendees, lengthInMinutes: scrumTimer.secondsElapsed/60)
let newHistory=History(attendees: scrum.attendees, lengthInMinutes: scrumTimer.secondsElapsed/60,transcript:transcript)
scrum.history.insert(newHistory, at: 0)
}
}
Expand Down

0 comments on commit 87bc990

Please sign in to comment.