SwiftUI_Crud 單字怎麼背
Published in
3 min readMay 19, 2020
(一)GIF螢幕截圖
(二)Github連結
(三)作業說明
基本功能都有做到,分析圖兩種分別為圓餅圖和圓環進度條,
加分及特色功能在以下說明:
(1)onMove調整資料順序
.onMove { (indexSet, index) in self.wordsData.Words.move(fromOffsets: indexSet, toOffset: index)}
(2)圖表加上動畫效果
Circle() .trim(from: 0, to: trimEnd) .stroke(Color.blue, style: StrokeStyle(lineWidth: 30, lineCap: .round)) .frame(width: 300, height: 300) .animation(.linear(duration: 1)) .onAppear {self.trimEnd = CGFloat(self.process)}
(3)資料搜尋功能(SearchBar.swift+以下程式碼片段)
var filterWords: [Word] {return wordsData.Words.filter({ searchText.isEmpty ? true : $0.words.contains(searchText) })}ForEach(filterWords)
(4)TextField可以根據不同長度的文字做長度判斷
(可參考multilineTextField.swift)
(5)學習計畫(WebView)是嵌入一個單字學習網頁,原本是要實作但時間不夠就用這種方法了,這網站使用的方法就是輸入一天要背幾個單字,總共要背幾組,按下生成後會列出像上面一樣的背單字計劃表