-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wx source, accounts, about settings, error modal
- Loading branch information
Showing
16 changed files
with
527 additions
and
125 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { FC, ReactNode, useContext } from "react"; | ||
|
||
import { ContentPageContainer } from "./components/ContentPageContainer"; | ||
import { ItemGroup } from "../../components/ItemGroup"; | ||
import styled from "styled-components"; | ||
import { ListItem } from "../../components/ListItem"; | ||
|
||
import saltyLogo from "../../img/salty-logo.svg"; | ||
|
||
export const About: FC = () => ( | ||
<ContentPageContainer title="About" backProps={{ label: "General", path: "/settings/general" }}> | ||
<ItemGroup> | ||
<ListItem> | ||
<Name>Name</Name> | ||
<Value>saltPad</Value> | ||
</ListItem> | ||
<ListItem> | ||
<Name>saltPadOS Version</Name> | ||
<Value>1.0</Value> | ||
</ListItem> | ||
<ListItem> | ||
<Name>74S Version</Name> | ||
<Value>0.7.0</Value> | ||
</ListItem> | ||
</ItemGroup> | ||
<LicenseContainer> | ||
<div className="margin">Copyright (C) 2024 Salty Simulations and its contributors</div> | ||
<div className="margin"> | ||
This program 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. | ||
</div> | ||
<div> | ||
This program 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. | ||
</div> | ||
<div className="me">Written with <3 by Natalie <[email protected]></div> | ||
</LicenseContainer> | ||
<img src={saltyLogo} width={350} /> | ||
</ContentPageContainer> | ||
); | ||
|
||
|
||
|
||
const Name = styled.div` | ||
margin: 0 25px; | ||
`; | ||
|
||
const Value = styled.div` | ||
margin: 0 25px; | ||
color: gray; | ||
`; | ||
|
||
const LicenseContainer = styled.div` | ||
padding: 25px; | ||
background: white; | ||
border-radius: 25px; | ||
margin-bottom: 50px; | ||
text-align: start; | ||
font-size: 22px; | ||
border: 1px solid lightgray; | ||
.me { | ||
margin-top: 16px; | ||
} | ||
.margin { | ||
margin-bottom: 8px; | ||
} | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React, { FC, useContext } from "react"; | ||
|
||
import { ContentPageContainer } from "./components/ContentPageContainer"; | ||
import { ItemGroup } from "../../components/ItemGroup"; | ||
import { NavigationItem } from "./components/NavigationItem"; | ||
import { ListItem } from "../../components/ListItem"; | ||
import { Input } from "../../components/Input"; | ||
import { useSetting } from "../../hooks/useSettings"; | ||
import { SimbriefClient } from "@microsoft/msfs-sdk"; | ||
import { ModalContext } from "../.."; | ||
import { InfoModal } from "../../components/InfoModal"; | ||
|
||
export const Accounts: FC = () => { | ||
const [simbriefUsername, setSimbriefUsername] = useSetting("boeingMsfsSimbriefUsername"); | ||
const [, setSimbriefId] = useSetting("boeingMsfsSimbriefUserID"); | ||
const { setModal } = useContext(ModalContext); | ||
|
||
const handleSimbriefInput = async (input: string) => { | ||
try { | ||
const userId = await SimbriefClient.getSimbriefUserIDFromUsername(input); | ||
setSimbriefUsername(input); | ||
setSimbriefId(userId); | ||
} catch (_) { | ||
setModal(<InfoModal title="Error" description={`Invalid SimBrief username "${input}"`} />); | ||
} | ||
}; | ||
|
||
return ( | ||
<ContentPageContainer title="Accounts"> | ||
<ItemGroup> | ||
<ListItem> | ||
<div className="side">SimBrief Username</div> | ||
<Input | ||
placeholder={simbriefUsername ? simbriefUsername.toString().toLowerCase() : "..."} | ||
centerPlaceholder={false} | ||
placeholderAlign="right" | ||
style={{ borderBottom: "none", textAlign: "right", margin: "0 15px", fontSize: "26px" }} | ||
onFocusOut={handleSimbriefInput} | ||
clearOnFocusOut | ||
/> | ||
</ListItem> | ||
<NavigationItem name="Navigraph" path="/fzpro" /> | ||
</ItemGroup> | ||
</ContentPageContainer> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { FC, ReactNode, useState } from "react"; | ||
import { usePersistentProperty, usePersistentPropertyWithDefault } from "react-msfs"; | ||
import { AtisSource, MetarSource, TafSource } from "../../lib/weather"; | ||
|
||
type SettingsContextProps = { | ||
metarSource: MetarSource; | ||
setMetarSource: (source: MetarSource) => void; | ||
tafSource: TafSource; | ||
setTafSource: (source: TafSource) => void; | ||
atisSource: AtisSource; | ||
setAtisSource: (source: AtisSource) => void; | ||
}; | ||
|
||
const defaults: Pick<SettingsContextProps, "metarSource" | "tafSource" | "atisSource"> = { | ||
metarSource: "msfs", | ||
tafSource: "aviationweather", | ||
atisSource: "vatsim", | ||
}; | ||
|
||
export const SettingsContext = React.createContext<SettingsContextProps>({ | ||
metarSource: defaults.metarSource, | ||
setMetarSource: () => {}, | ||
tafSource: defaults.tafSource, | ||
setTafSource: () => {}, | ||
atisSource: defaults.atisSource, | ||
setAtisSource: () => {}, | ||
}); | ||
|
||
export const SettingsContextProvider: FC<{ children: ReactNode | ReactNode[] }> = ({ children }) => { | ||
const [metarSource, setMetarSource] = usePersistentPropertyWithDefault("SALTY_METAR_SOURCE", defaults.metarSource) as [ | ||
MetarSource, | ||
(s: MetarSource) => void | ||
]; | ||
const [tafSource, setTafSource] = usePersistentPropertyWithDefault("SALTY_TAF_SOURCE", defaults.tafSource) as [ | ||
TafSource, | ||
(s: TafSource) => void]; | ||
|
||
const [atisSource, setAtisSource] = usePersistentPropertyWithDefault("SALTY_ATIS_SOURCE", defaults.atisSource) as [ | ||
AtisSource, | ||
(s: AtisSource) => void | ||
]; | ||
|
||
return ( | ||
<SettingsContext.Provider | ||
value={{ | ||
metarSource, | ||
setMetarSource, | ||
tafSource, | ||
setTafSource, | ||
atisSource, | ||
setAtisSource, | ||
}} | ||
> | ||
{children} | ||
</SettingsContext.Provider> | ||
); | ||
}; |
Oops, something went wrong.