changeset 211:43a05e129bad

Add language News
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Sat, 27 Feb 2021 12:44:55 +0000
parents 4cdd0b7f807c
children e7fc442ccdc8
files LazyBear/UI/NewsRow.swift LazyBear/UI/NewsView.swift
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/LazyBear/UI/NewsRow.swift	Sat Feb 27 12:44:23 2021 +0000
+++ b/LazyBear/UI/NewsRow.swift	Sat Feb 27 12:44:55 2021 +0000
@@ -40,8 +40,6 @@
                         .font(.caption2)
                         .opacity(0.5)
                 }
-                
-                Text(new.lang ?? "Nil")
             }
         }
         .padding(.horizontal)
--- a/LazyBear/UI/NewsView.swift	Sat Feb 27 12:44:23 2021 +0000
+++ b/LazyBear/UI/NewsView.swift	Sat Feb 27 12:44:55 2021 +0000
@@ -11,11 +11,17 @@
     var symbol: String
     @State var news = [NewsModel]()
     
+    @FetchRequest(entity: UserSettings.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \UserSettings.changedAt, ascending: false)])
+    var userSettings: FetchedResults<UserSettings>
+    
     var body: some View {
         VStack(alignment: .leading) {
+            let language = userSettings.first?.newsLanguage ?? "en"
             ForEach(news, id: \.self) { new in
-                NewsRow(new: new)
-                Divider()
+                if language == new.lang {
+                    NewsRow(new: new)
+                    Divider()
+                }
             }
         }
         .onAppear {