-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from simple-login/feat/show-stats
feat: show stats
- Loading branch information
Showing
9 changed files
with
89 additions
and
11 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
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
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
62 changes: 62 additions & 0 deletions
62
SimpleLogin/SimpleLogin/Modules/Main/Aliases/StatsView.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,62 @@ | ||
// | ||
// StatsView.swift | ||
// SimpleLogin - Created on 07/02/2024. | ||
// Copyright (c) 2024 Proton Technologies AG | ||
// | ||
// This file is part of SimpleLogin. | ||
// | ||
// SimpleLogin is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// SimpleLogin is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with SimpleLogin. If not, see https://www.gnu.org/licenses/. | ||
// | ||
|
||
import SimpleLoginPackage | ||
import SwiftUI | ||
|
||
struct StatsView: View { | ||
let stats: Stats | ||
|
||
var body: some View { | ||
VStack { | ||
HStack { | ||
cell(title: "Aliases", description: "All time", count: stats.aliasCount) | ||
cell(title: "Forwarded", description: "Last 14 days", count: stats.forwardCount) | ||
} | ||
|
||
HStack { | ||
cell(title: "Replies/send", description: "Last 14 days", count: stats.replyCount) | ||
cell(title: "Blocked", description: "Last 14 days", count: stats.blockCount) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private extension StatsView { | ||
func cell(title: String, description: String, count: Int) -> some View { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Text(title) | ||
.font(.footnote.weight(.medium)) | ||
Spacer() | ||
Text(description) | ||
.font(.caption) | ||
.foregroundStyle(Color.secondary) | ||
} | ||
Text("\(count)") | ||
.font(.title2.bold()) | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding(10) | ||
.background(Color.secondary.opacity(0.1)) | ||
.clipShape(RoundedRectangle(cornerRadius: 8)) | ||
} | ||
} |