Skip to content

Commit

Permalink
V5.0.5 (#44)
Browse files Browse the repository at this point in the history
iOS apps and server code for v5.0.5. New scouting interface, more data collection, and minor bugfixes.

**commits**

* fix shit

* completely rework scouting interface

pill shaped goofy gear shifter type interface

* new data things

* numbers

* •_•

* blackjack points

* stop the server from crashing when you gamble

* app store 5.0.5 release
  • Loading branch information
JayAgra authored Feb 29, 2024
1 parent 5991e7b commit ab57dd6
Show file tree
Hide file tree
Showing 47 changed files with 1,176 additions and 233 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bear_tracks"
version = "5.0.4"
version = "5.0.5"
edition = "2021"
authors = ["Jayen Agrawal"]
description = "a scouting app for frc"
Expand Down
25 changes: 23 additions & 2 deletions ios/TeamViewStats.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ struct TeamViewStats: View {
}
.frame(maxWidth: .infinity)
VStack {
Text("\(String(getRelevantData(item: teamDetail.teamData[0].total)))")
Text("\(String(getRelevantData(item: teamDetail.teamData[0].auto_scores)))")
.font(.title)
Text("total")
Text("auto scores")
}
.frame(maxWidth: .infinity)
}
Expand All @@ -98,6 +98,27 @@ struct TeamViewStats: View {
.frame(maxWidth: .infinity)
}
.padding([.top, .bottom])
HStack {
VStack {
Text("\(String(getRelevantData(item: teamDetail.teamData[0].auto_preload)))")
.font(.title)
Text("auto preload")
}
.frame(maxWidth: .infinity)
VStack {
Text("\(String(getRelevantData(item: teamDetail.teamData[0].auto_wing)))")
.font(.title)
Text("auto wing")
}
.frame(maxWidth: .infinity)
VStack {
Text("\(String(getRelevantData(item: teamDetail.teamData[0].auto_center)))")
.font(.title)
Text("auto center")
}
.frame(maxWidth: .infinity)
}
.padding([.top, .bottom])
HStack {
VStack {
Text("\(String(getRelevantData(item: teamDetail.teamData[0].points))) pts")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions ios/beartracks/SystemStatus/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
11 changes: 11 additions & 0 deletions ios/beartracks/SystemStatus/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widgetkit-extension</string>
</dict>
</dict>
</plist>
16 changes: 16 additions & 0 deletions ios/beartracks/SystemStatus/SystemStatusBundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// SystemStatusBundle.swift
// SystemStatus
//
// Created by Jayen Agrawal on 2/27/24.
//

import WidgetKit
import SwiftUI

@main
struct SystemStatusBundle: WidgetBundle {
var body: some Widget {
SystemStatusLiveActivity()
}
}
122 changes: 122 additions & 0 deletions ios/beartracks/SystemStatus/SystemStatusLiveActivity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
//
// SystemStatusLiveActivity.swift
// SystemStatus
//
// Created by Jayen Agrawal on 2/27/24.
//

import ActivityKit
import WidgetKit
import SwiftUI

struct SystemStatusAttributes: ActivityAttributes {
public struct ContentState: Codable, Hashable {
var total_mem: Int
var used_mem: Int
var total_swap: Int
var used_swap: Int
var uptime: Int
var load_one: Double
var load_five: Double
var load_fifteen: Double
var sessions: Int
}
var hostname: String
}

struct SystemStatusLiveActivity: Widget {
var body: some WidgetConfiguration {
ActivityConfiguration(for: SystemStatusAttributes.self) { context in
// Lock screen/banner UI goes here
VStack {
HStack {
ProgressView(value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0) {
Text("RAM\n\(Int(Float(context.state.used_mem) / Float(context.state.total_mem) * 100))%")
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
Spacer()
ProgressView(value: context.state.load_five, total: 1.0) {
Text("CPU\n\(Int(context.state.load_five * 100))%")
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
}
Text("\(context.state.sessions) active sessions")
}
.padding()
.activityBackgroundTint(Color.black)
.activitySystemActionForegroundColor(Color.white)

} dynamicIsland: { context in
DynamicIsland {
DynamicIslandExpandedRegion(.leading) {
ProgressView(value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0) {
Text("RAM\n\(Int(100 * Float(context.state.used_mem) / Float(context.state.total_mem)))%")
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
}
DynamicIslandExpandedRegion(.trailing) {
ProgressView(value: context.state.load_five, total: 1.0) {
Text("CPU\n\(Int((context.state.load_five * 100).rounded()))%")
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
}
DynamicIslandExpandedRegion(.bottom) {
Text("\(context.state.sessions) active sessions")
}
} compactLeading: {
ProgressView(value: Float(context.state.used_mem) / Float(context.state.total_mem), total: 1.0) {
Label("RAM", systemImage: "memorychip")
.labelStyle(.iconOnly)
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.used_mem) / Float(context.state.total_mem))))
} compactTrailing: {
ProgressView(value: context.state.load_five, total: 1.0) {
Label("5m Load", systemImage: "gauge.open.with.lines.needle.33percent")
.labelStyle(.iconOnly)
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
} minimal: {
ProgressView(value: context.state.load_five, total: 1.0) {
Label("5m Load", systemImage: "gauge.open.with.lines.needle.33percent")
.labelStyle(.iconOnly)
}
.progressViewStyle(CircularProgressViewStyle(tint: getColor(value: Float(context.state.load_five))))
}
.widgetURL(URL(string: "https://beartracks.io"))
.keylineTint(Color.red)
}
}

private func getColor(value: Float) -> Color {
if value > 0.9 {
return Color.red
} else if value > 0.8 {
return Color.yellow
} else {
return Color.green
}
}
}

extension SystemStatusAttributes {
fileprivate static var preview: SystemStatusAttributes {
SystemStatusAttributes(hostname: "beartracks.io")
}
}

extension SystemStatusAttributes.ContentState {
fileprivate static var smiley: SystemStatusAttributes.ContentState {
SystemStatusAttributes.ContentState.init(total_mem: 1000, used_mem: 839, total_swap: 0, used_swap: 0, uptime: 2313124, load_one: 0.02, load_five: 0.40, load_fifteen: 0.93, sessions: 2)
}

fileprivate static var starEyes: SystemStatusAttributes.ContentState {
SystemStatusAttributes.ContentState.init(total_mem: 1000, used_mem: 839, total_swap: 100, used_swap: 0, uptime: 2313124, load_one: 0.02, load_five: 0.40, load_fifteen: 0.93, sessions: 2)
}
}

#Preview("Notification", as: .content, using: SystemStatusAttributes.preview) {
SystemStatusLiveActivity()
} contentStates: {
SystemStatusAttributes.ContentState.smiley
SystemStatusAttributes.ContentState.starEyes
}
8 changes: 4 additions & 4 deletions ios/beartracks/bearTracks.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
CODE_SIGN_ENTITLEMENTS = bearTracks/bearTracks.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_ASSET_PATHS = "\"bearTracks/Preview Content\"";
DEVELOPMENT_TEAM = D6MFYYVHA8;
ENABLE_PREVIEWS = YES;
Expand All @@ -378,7 +378,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.4;
MARKETING_VERSION = 5.0.5;
PRODUCT_BUNDLE_IDENTIFIER = com.jayagra.beartracks;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand All @@ -399,7 +399,7 @@
CODE_SIGN_ENTITLEMENTS = bearTracks/bearTracks.entitlements;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 14;
DEVELOPMENT_ASSET_PATHS = "\"bearTracks/Preview Content\"";
DEVELOPMENT_TEAM = D6MFYYVHA8;
ENABLE_PREVIEWS = YES;
Expand All @@ -419,7 +419,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 5.0.4;
MARKETING_VERSION = 5.0.5;
PRODUCT_BUNDLE_IDENTIFIER = com.jayagra.beartracks;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "l0_icon2.png",
"filename" : "l0_sprite_4.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion ios/beartracks/bearTracks/DetailedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,41 @@ struct DetailedView: View {
Spacer()
Text("\(matchTime.intake == 1 ? "" : "")")
.font(.title3)
case 5:
Text("Auto Neutral Handle")
.font(.title3)
Spacer()
Text("\(Int(matchTime.intake))")
.font(.title3)
case 6:
Text("Auto Wing Handle")
.font(.title3)
Spacer()
Text("\(Int(matchTime.intake))")
.font(.title3)
case 7:
Text("Auto Preload Handle")
.font(.title3)
Spacer()
Text("\(Int(matchTime.intake))")
.font(.title3)
case 8:
Text("Auto Scores")
.font(.title3)
Spacer()
Text("\(Int(matchTime.intake))")
.font(.title3)
case 9:
Text("Shuttle")
.font(.title3)
Spacer()
Text("\(String(format: "%.1f", matchTime.intake + matchTime.travel + matchTime.outtake))s")
.font(.title3)
default:
Text("Unknown entry")
}
}
if matchTime.score_type == 0 || matchTime.score_type == 1 {
if matchTime.score_type == 0 || matchTime.score_type == 1 || matchTime.score_type == 9 {
HStack {
Spacer()
Label(String(format: "%.1f", matchTime.intake), systemImage: "tray.and.arrow.down")
Expand Down
10 changes: 8 additions & 2 deletions ios/beartracks/bearTracks/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct LoginView: View {
VStack {
Text("bearTracks")
.font(.title)
Text("v5.0.4 • 2024")
Text("v5.0.5 • 2024")
if !loading {
if !create {
Text("log in")
Expand Down Expand Up @@ -125,7 +125,13 @@ struct LoginView: View {
alertMessage = "bad credentials"
} else {
if httpResponse.statusCode == 400 {
alertMessage = "you supplied some data the server didn't like very much. your username could have been taken or your team code was invalid. alternatively, either your username, full name, or password was not between 3 and 32 characters (8 min for password) or they contained special characters other than \"-\" or \"_\"."
alertMessage = "you supplied some data the server didn't like very much. your username, full name, and/or password contained characters other than a-z 0-9 A-Z - ~ ! @ # $ % ^ & * ( ) = + / \\ _ [ _ ] { } | ? . ,"
} else if httpResponse.statusCode == 409 {
alertMessage = "username taken"
} else if httpResponse.statusCode == 403 {
alertMessage = "bad access key"
} else if httpResponse.statusCode == 413 {
alertMessage = "your username, full name, and/or password were not between 3 and 64 characters (8 min for password)"
} else {
alertMessage = "creation failed"
}
Expand Down
7 changes: 2 additions & 5 deletions ios/beartracks/bearTracks/TeamStatController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ class TeamStatController: ObservableObject {
struct TeamStats: Codable {
let team: Int
let trap_note, climb, buddy_climb: Double?
let intake, travel, outtake, speaker, amplifier, total, points: DataStats
}

struct DataStats: Codable {
let first, median, third, mean, decaying: Int
let intake, travel, outtake, speaker, amplifier, total, points, auto_preload, auto_wing, auto_center, auto_scores: DataStats
}

struct DataStats: Codable { let first, median, third, mean, decaying: Int }
Loading

0 comments on commit ab57dd6

Please sign in to comment.