-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Twitter with Mastodon feed (#488)
- Loading branch information
Showing
44 changed files
with
737 additions
and
1,204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
CriticalMapsKit/Sources/ApiClient/Requests/TwitterFeedRequest.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
CriticalMapsKit/Sources/MastodonFeedFeature/Dependencies.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import ComposableArchitecture | ||
import Foundation | ||
|
||
private enum MastodonServiceKey: DependencyKey { | ||
static let liveValue = TootService.live() | ||
static let testValue = TootService.noop | ||
} | ||
|
||
|
||
public extension DependencyValues { | ||
var tootService: TootService { | ||
get { self[MastodonServiceKey.self] } | ||
set { self[MastodonServiceKey.self] = newValue } | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
CriticalMapsKit/Sources/MastodonFeedFeature/MastodonFeedView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import ComposableArchitecture | ||
import Foundation | ||
import MastodonKit | ||
import SharedModels | ||
import Styleguide | ||
import SwiftUI | ||
|
||
public struct MastodonFeedView: View { | ||
public struct MastodonFeedViewState: Equatable { | ||
public let displayPlaceholder: Bool | ||
|
||
public init(_ state: TootFeedFeature.State) { | ||
if state.isLoading && !state.isRefreshing { | ||
displayPlaceholder = true | ||
} else { | ||
displayPlaceholder = false | ||
} | ||
} | ||
} | ||
|
||
let store: StoreOf<TootFeedFeature> | ||
@ObservedObject var viewStore: ViewStore<MastodonFeedViewState, TootFeedFeature.Action> | ||
|
||
public init(store: StoreOf<TootFeedFeature>) { | ||
self.store = store | ||
viewStore = ViewStore(store.scope(state: MastodonFeedViewState.init, action: { $0 })) | ||
} | ||
|
||
public var body: some View { | ||
TootsListView(store: self.store) | ||
.navigationBarTitleDisplayMode(.inline) | ||
.onAppear { viewStore.send(.onAppear) } | ||
} | ||
} | ||
|
||
// MARK: Preview | ||
|
||
struct MastodonFeedView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
MastodonFeedView( | ||
store: Store<TootFeedFeature.State, TootFeedFeature.Action>( | ||
initialState: .init(), | ||
reducer: TootFeedFeature()._printChanges() | ||
) | ||
) | ||
} | ||
} | ||
|
||
public extension Array where Element == MastodonKit.Status { | ||
static let placeHolder: Self = [0, 1, 2, 3, 4].map { | ||
Status( | ||
id: String($0), | ||
uri: "", | ||
url: nil, | ||
account: .init( | ||
id: String($0), | ||
username: "@criticalmaps", | ||
acct: "@[email protected]", | ||
displayName: "Critical Maps", | ||
note: "", | ||
url: "", | ||
avatar: "", | ||
avatarStatic: "", | ||
header: "", | ||
headerStatic: "", | ||
locked: false, | ||
createdAt: .init(timeIntervalSince1970: TimeInterval(1635521516)), | ||
followersCount: 11, | ||
followingCount: 8, | ||
statusesCount: 0 | ||
), | ||
inReplyToID: nil, | ||
inReplyToAccountID: nil, | ||
content: String("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed invidunt ut labore et dolore".dropLast($0)), | ||
createdAt: .init(timeIntervalSince1970: TimeInterval(1635521516)), | ||
emojis: [], | ||
reblogsCount: 0, | ||
favouritesCount: 0, | ||
reblogged: nil, | ||
favourited: nil, | ||
bookmarked: nil, | ||
sensitive: nil, | ||
spoilerText: "", | ||
visibility: .public, | ||
mediaAttachments: [], | ||
mentions: [], | ||
tags: [], | ||
application: nil, | ||
language: nil, | ||
reblog: nil, | ||
pinned: nil, | ||
card: nil, | ||
repliesCount: 0 | ||
) | ||
} | ||
} | ||
|
||
extension Store where State == TootFeedFeature.State, Action == TootFeedFeature.Action { | ||
static let placeholder = Store( | ||
initialState: .init( | ||
toots: IdentifiedArray( | ||
uniqueElements: [MastodonKit.Status].placeHolder | ||
) | ||
), | ||
reducer: EmptyReducer() | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.