-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: native google login option & matching statusbar color in native…
… devices
- Loading branch information
1 parent
22ec3bc
commit 0dfeaee
Showing
27 changed files
with
365 additions
and
284 deletions.
There are no files selected for viewing
11 changes: 10 additions & 1 deletion
11
android/app/src/main/java/com/notes/homocodians/MainActivity.java
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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
package com.notes.homocodians; | ||
|
||
import android.os.Bundle; | ||
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth; | ||
import com.getcapacitor.BridgeActivity; | ||
|
||
public class MainActivity extends BridgeActivity {} | ||
public class MainActivity extends BridgeActivity { | ||
|
||
public void onCreate(Bundle savedInstanceState){ | ||
super.onCreate(savedInstanceState); | ||
|
||
registerPlugin(GoogleAuth.class); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,99 @@ | ||
import { HTMLInputTypeAttribute, useState } from "react"; | ||
import { HTMLInputTypeAttribute, useRef, useState } from "react"; | ||
|
||
import { | ||
Dialog, | ||
Button, | ||
TextField, | ||
DialogTitle, | ||
DialogContent, | ||
DialogActions, | ||
CircularProgress, | ||
DialogContentText, | ||
Dialog, | ||
Button, | ||
TextField, | ||
DialogTitle, | ||
DialogContent, | ||
DialogActions, | ||
CircularProgress, | ||
DialogContentText, | ||
} from "@mui/material"; | ||
import Box from "@mui/system/Box"; | ||
import toast from "react-hot-toast"; | ||
|
||
type FormDialogProps = { | ||
isOpen: boolean; | ||
setOpen: (isOpen: boolean) => void; | ||
title: string; | ||
content: string; | ||
textFieldLabel: string; | ||
textFieldType: HTMLInputTypeAttribute; | ||
positiveButtonLabel: string; | ||
TextFieldcolor?: | ||
| "error" | ||
| "primary" | ||
| "secondary" | ||
| "info" | ||
| "success" | ||
| "warning"; | ||
positiveButtonAction: (value: string, cb: () => void) => void; | ||
isOpen: boolean; | ||
setOpen: (isOpen: boolean) => void; | ||
title: string; | ||
content: string; | ||
textFieldLabel: string; | ||
textFieldType: HTMLInputTypeAttribute; | ||
positiveButtonLabel: string; | ||
TextFieldcolor?: | ||
| "error" | ||
| "primary" | ||
| "secondary" | ||
| "info" | ||
| "success" | ||
| "warning"; | ||
positiveButtonAction: (value: string, cb: () => void) => void; | ||
}; | ||
|
||
function FormDialog({ | ||
title, | ||
isOpen, | ||
setOpen, | ||
content, | ||
textFieldLabel, | ||
textFieldType, | ||
positiveButtonLabel, | ||
positiveButtonAction, | ||
TextFieldcolor, | ||
title, | ||
isOpen, | ||
setOpen, | ||
content, | ||
textFieldLabel, | ||
textFieldType, | ||
positiveButtonLabel, | ||
positiveButtonAction, | ||
TextFieldcolor, | ||
}: FormDialogProps) { | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const inputRef = useRef<HTMLInputElement>(); | ||
|
||
const handleClose = () => { | ||
setOpen(false); | ||
}; | ||
const handleClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
const handlePositiveClick = () => { | ||
setIsLoading(true); | ||
const input = document.getElementById("name") as HTMLInputElement; | ||
if (input.value) { | ||
positiveButtonAction(input.value, () => { | ||
setIsLoading(false); | ||
}); | ||
} | ||
}; | ||
const handlePositiveClick = () => { | ||
setIsLoading(true); | ||
const input = inputRef.current; | ||
if (input && input.value) { | ||
positiveButtonAction(input.value, () => { | ||
setIsLoading(false); | ||
}); | ||
} else { | ||
setIsLoading(false); | ||
toast.error("Invalid email"); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Dialog open={isOpen} onClose={handleClose}> | ||
<DialogTitle>{title}</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText>{content}</DialogContentText> | ||
<TextField | ||
autoFocus | ||
margin="dense" | ||
id="name" | ||
label={textFieldLabel} | ||
type={textFieldType} | ||
autoComplete={textFieldType === "email" ? "email" : "text"} | ||
fullWidth | ||
variant="standard" | ||
color={TextFieldcolor} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleClose}>Cancel</Button> | ||
{isLoading ? ( | ||
<Box mx={2}> | ||
<CircularProgress size={25} /> | ||
</Box> | ||
) : ( | ||
<Button onClick={handlePositiveClick}>{positiveButtonLabel}</Button> | ||
)} | ||
</DialogActions> | ||
</Dialog> | ||
</div> | ||
); | ||
return ( | ||
<div> | ||
<Dialog open={isOpen} onClose={handleClose}> | ||
<DialogTitle>{title}</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText>{content}</DialogContentText> | ||
<TextField | ||
autoFocus | ||
margin="dense" | ||
id="name" | ||
label={textFieldLabel} | ||
type={textFieldType} | ||
autoComplete={textFieldType === "email" ? "email" : "text"} | ||
fullWidth | ||
variant="standard" | ||
color={TextFieldcolor} | ||
inputRef={inputRef} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleClose}>Cancel</Button> | ||
{isLoading ? ( | ||
<Box mx={2}> | ||
<CircularProgress size={25} /> | ||
</Box> | ||
) : ( | ||
<Button onClick={handlePositiveClick}>{positiveButtonLabel}</Button> | ||
)} | ||
</DialogActions> | ||
</Dialog> | ||
</div> | ||
); | ||
} | ||
|
||
export default FormDialog; |
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,20 @@ | ||
import { Toaster } from "react-hot-toast"; | ||
import { useTernaryDarkMode } from "usehooks-ts"; | ||
|
||
function ThemedToaster() { | ||
const { isDarkMode } = useTernaryDarkMode(); | ||
return ( | ||
<Toaster | ||
toastOptions={{ | ||
position: "bottom-center", | ||
style: { | ||
backgroundColor: !isDarkMode ? "#121212" : undefined, | ||
color: !isDarkMode ? "#ffffff" : undefined, | ||
borderRadius: 999, | ||
}, | ||
}} | ||
/> | ||
); | ||
} | ||
|
||
export default ThemedToaster; |
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.