-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move sending of messages to top level.
Refactor sharing actions UI.
- Loading branch information
1 parent
1389376
commit d9c6f29
Showing
10 changed files
with
108 additions
and
193 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,25 +1,32 @@ | ||
import { IonCard, IonCardHeader, IonCardTitle, IonCardContent } from "@ionic/react"; | ||
import React from "react"; | ||
import { SessionActionsList } from "../session-actions/SessionActionsList"; | ||
import { WSClient } from "../../WSClient"; | ||
import { IonCard, IonCardHeader, IonCardTitle, IonCardContent, IonButton, IonModal } from "@ionic/react"; | ||
import React, { useState } from "react"; | ||
import { SessionMessage, SessionMessageType } from "../session/SessionMessage"; | ||
import { ShareModal } from "./share-actions/ShareModal"; | ||
|
||
export type ShareCardProps = { | ||
wsClient: WSClient; | ||
sessionOwnerId?: string; | ||
onShare: (msg: SessionMessage) => void; | ||
userIsSessionOwner?: boolean; | ||
} | ||
|
||
export const ShareCard: React.FC<ShareCardProps> = ({wsClient, sessionOwnerId}) => { | ||
return <IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle>Share</IonCardTitle> | ||
</IonCardHeader> | ||
<IonCardContent> | ||
<SessionActionsList | ||
wsClient={wsClient} | ||
userIsSessionOwner={ | ||
sessionOwnerId === wsClient.getId() | ||
} | ||
></SessionActionsList> | ||
</IonCardContent> | ||
</IonCard>; | ||
}; | ||
export const ShareCard: React.FC<ShareCardProps> = ({onShare, userIsSessionOwner}) => { | ||
const [shareModalTypeOpen, setShareModalTypeOpen] = useState<SessionMessageType | null>(null); | ||
|
||
return <IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle>Share</IonCardTitle> | ||
</IonCardHeader> | ||
<IonCardContent> | ||
{/* Send text message */} | ||
<IonButton | ||
onClick={() => setShareModalTypeOpen("TEXT_MESSAGE")} | ||
>Send Message</IonButton> | ||
</IonCardContent> | ||
<IonModal isOpen={shareModalTypeOpen != null} onDidDismiss={() => setShareModalTypeOpen(null)}> | ||
<ShareModal | ||
type={shareModalTypeOpen} | ||
onShare={onShare} | ||
closeModal={() => setShareModalTypeOpen(null)} | ||
/> | ||
</IonModal> | ||
</IonCard>; | ||
}; |
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,34 @@ | ||
import { IonButton, IonInput } from "@ionic/react"; | ||
import React, { useState } from "react"; | ||
import { ShareModalProps } from "./ShareModal"; | ||
import { SessionMessage } from "../../session/SessionMessage"; | ||
|
||
export const SendMessageModal: React.FC<ShareModalProps> = ({ | ||
onShare, | ||
closeModal, | ||
}) => { | ||
|
||
const [text, setText] = useState(""); | ||
|
||
const sendClick = () => { | ||
let sessionMsg: SessionMessage = { | ||
type: "TEXT_MESSAGE", | ||
text: text, | ||
}; | ||
onShare(sessionMsg); | ||
closeModal(); | ||
}; | ||
|
||
return ( | ||
<div style={{display: "flex", flexDirection: "column"}}> | ||
<h1>Send message</h1> | ||
<p>Send message to all clients in this session.</p> | ||
<IonInput | ||
value={text} | ||
placeholder="Enter message to send" | ||
onIonChange={(e) => setText(e.detail.value!)} | ||
></IonInput> | ||
<IonButton onClick={() => sendClick()}>Send</IonButton> | ||
</div> | ||
); | ||
} |
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 React from "react"; | ||
import { SessionMessage, SessionMessageType } from "../../session/SessionMessage"; | ||
import { SendMessageModal } from "./SendMessageModal"; | ||
|
||
export type ShareModalProps = { | ||
type: SessionMessageType | null; | ||
onShare: (msg: SessionMessage) => void; | ||
closeModal: () => any; | ||
}; | ||
|
||
export const ShareModal: React.FC<ShareModalProps> = ({type, onShare, closeModal}) => { | ||
switch(type) { | ||
case "TEXT_MESSAGE": return <SendMessageModal | ||
type="TEXT_MESSAGE" | ||
onShare={onShare} | ||
closeModal={closeModal} | ||
/> | ||
default: return null; | ||
} | ||
} |