Archived
Added strikethroughs to room strings if they contain "?"
This commit is contained in:
@@ -35,7 +35,7 @@ class DataFetcher {
|
|||||||
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
|
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
|
||||||
DispatchQueue(label: "work-queue").async {
|
DispatchQueue(label: "work-queue").async {
|
||||||
let foodUrl = "https://djd4rkn355.github.io/food.html"
|
let foodUrl = "https://djd4rkn355.github.io/food.html"
|
||||||
let url = "https://djd4rkn355.github.io/subst.html"
|
let url = "https://djd4rkn355.github.io/subst_test.html"
|
||||||
Alamofire.request(url).responseString { response in
|
Alamofire.request(url).responseString { response in
|
||||||
if let html = response.result.value {
|
if let html = response.result.value {
|
||||||
Alamofire.request(foodUrl).responseString { response in
|
Alamofire.request(foodUrl).responseString { response in
|
||||||
@@ -282,7 +282,7 @@ class DataFetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getColourPalette() -> [UIColor] {
|
func getColourPalette() -> [UIColor] {
|
||||||
return [#colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0), #colorLiteral(red: 1, green: 0.4932718873, blue: 0.4739984274, alpha: 1), #colorLiteral(red: 1, green: 0.5781051517, blue: 0, alpha: 1), #colorLiteral(red: 0.9995340705, green: 0.988355577, blue: 0.4726552367, alpha: 1), #colorLiteral(red: 0.4500938654, green: 0.9813225865, blue: 0.4743030667, alpha: 1), #colorLiteral(red: 0.4508578777, green: 0.9882974029, blue: 0.8376303315, alpha: 1), #colorLiteral(red: 0.4620226622, green: 0.8382837176, blue: 1, alpha: 1), #colorLiteral(red: 0.476841867, green: 0.5048075914, blue: 1, alpha: 1), #colorLiteral(red: 0.8446564078, green: 0.5145705342, blue: 1, alpha: 1), #colorLiteral(red: 1, green: 0.5409764051, blue: 0.8473142982, alpha: 1), #colorLiteral(red: 0.6745098039, green: 0.5568627451, blue: 0.4078431373, alpha: 1), #colorLiteral(red: 0.7540688515, green: 0.7540867925, blue: 0.7540771365, alpha: 1)]
|
return [#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1), #colorLiteral(red: 1, green: 0.4932718873, blue: 0.4739984274, alpha: 1), #colorLiteral(red: 1, green: 0.5781051517, blue: 0, alpha: 1), #colorLiteral(red: 0.9995340705, green: 0.988355577, blue: 0.4726552367, alpha: 1), #colorLiteral(red: 0.4500938654, green: 0.9813225865, blue: 0.4743030667, alpha: 1), #colorLiteral(red: 0.4508578777, green: 0.9882974029, blue: 0.8376303315, alpha: 1), #colorLiteral(red: 0.4620226622, green: 0.8382837176, blue: 1, alpha: 1), #colorLiteral(red: 0.476841867, green: 0.5048075914, blue: 1, alpha: 1), #colorLiteral(red: 0.8446564078, green: 0.5145705342, blue: 1, alpha: 1), #colorLiteral(red: 1, green: 0.5409764051, blue: 0.8473142982, alpha: 1), #colorLiteral(red: 0.6745098039, green: 0.5568627451, blue: 0.4078431373, alpha: 1), #colorLiteral(red: 0.7540688515, green: 0.7540867925, blue: 0.7540771365, alpha: 1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
func getColourPaletteNames() -> [String] {
|
func getColourPaletteNames() -> [String] {
|
||||||
|
|||||||
@@ -84,13 +84,20 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! PlanViewCell
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! PlanViewCell
|
||||||
cell.group.text = self.substs[indexPath.item].group
|
cell.group.text = self.substs[indexPath.item].group
|
||||||
cell.additional.text = self.substs[indexPath.item].additional
|
cell.additional.text = self.substs[indexPath.item].additional
|
||||||
cell.date.text = self.substs[indexPath.item].date
|
|
||||||
cell.time.text = self.substs[indexPath.item].time
|
cell.time.text = self.substs[indexPath.item].time
|
||||||
cell.room.text = self.substs[indexPath.item].room
|
cell.date.text = self.substs[indexPath.item].date
|
||||||
|
|
||||||
let course = self.substs[indexPath.item].course
|
let course = self.substs[indexPath.item].course
|
||||||
let image = df.getImage(from: course)
|
let image = df.getImage(from: course)
|
||||||
|
|
||||||
|
let roomMutable = NSMutableAttributedString(string: self.substs[indexPath.item].room)
|
||||||
|
let room = self.substs[indexPath.item].room
|
||||||
|
if let qmark = room.firstIndex(of: "?") {
|
||||||
|
let distance = room.distance(from: room.startIndex, to: qmark)
|
||||||
|
roomMutable.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 2, range: NSMakeRange(0, distance))
|
||||||
|
}
|
||||||
|
cell.room.attributedText = roomMutable
|
||||||
|
|
||||||
if image != nil {
|
if image != nil {
|
||||||
let attachment: NSTextAttachment = NSTextAttachment()
|
let attachment: NSTextAttachment = NSTextAttachment()
|
||||||
attachment.bounds = CGRect(x: 0, y: 0, width: 16, height: 16)
|
attachment.bounds = CGRect(x: 0, y: 0, width: 16, height: 16)
|
||||||
|
|||||||
Reference in New Issue
Block a user