-
Notifications
You must be signed in to change notification settings - Fork 5
System Level Chat messages
![Modderz Modderz logo](https://private-user-images.githubusercontent.com/47083513/287590152-264372d7-3802-4a75-b7f5-0d1b29bf40f9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8yODc1OTAxNTItMjY0MzcyZDctMzgwMi00YTc1LWI3ZjUtMGQxYjI5YmY0MGY5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNlNmJhOGU0MmI5Mjk2ZmI4M2QyZThhY2Y5MjllNmY4YmIwMjlhOTU3YzE4ZDM3YWUxNjY2YjMxNzMwY2U5NDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.gZ8q9-EJHz-A4NhFMm9lJrO1pVZ7OB0qR-Zx-nBEDVU)
![Modderz Modderz logo](https://private-user-images.githubusercontent.com/47083513/287590152-264372d7-3802-4a75-b7f5-0d1b29bf40f9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8yODc1OTAxNTItMjY0MzcyZDctMzgwMi00YTc1LWI3ZjUtMGQxYjI5YmY0MGY5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNlNmJhOGU0MmI5Mjk2ZmI4M2QyZThhY2Y5MjllNmY4YmIwMjlhOTU3YzE4ZDM3YWUxNjY2YjMxNzMwY2U5NDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.gZ8q9-EJHz-A4NhFMm9lJrO1pVZ7OB0qR-Zx-nBEDVU)
- Design Philosophy
- System level chats
- ChatScope
- Entire System level chats library
- Notice Messages
- Announce Messages
- ReSub Message
- Sub Messages
- AnonGift Messages
- GiftSub Messages
- Join Messages
- ChatErrorMessage
- We define
System level chats
as messages sent from the Twitch IRC servers and that are not sent by individual users
- All System level chat messages should have a distinct gradient color
- Naming conventions follow the Google naming convention standard, HERE
- All text sizes are defined at the ChatScope level
- All System level chats used through this application are surrounded by a ChatScope class. This follows the pattern described by Bumble tech design system article
- The entire library of System level components can be found HERE
-
NoticeMessages is a wrapper composable around the internal SystemMessageBox class
-
Composable function meant to display a system level event sent from the Twitch IRC servers. Read more about the NOTICE process
-
UI demonstration with code below:
![NoticeMessage](https://private-user-images.githubusercontent.com/47083513/324028175-75e80ff5-0587-4734-8eb5-071cf1c41e77.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwMjgxNzUtNzVlODBmZjUtMDU4Ny00NzM0LThlYjUtMDcxY2YxYzQxZTc3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI0MjAyNDBlYmNjOGZiZDZlMTdkYTQ0Y2YyNmEyMWFmZDkxMjU2MzhjMjg0ZDM4NDRiYWU2MTQzNTk1YmRkYzImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.AKln26HmJrk-XadbYgOazgvKoz1dWhNW1mX9zoQVdSQ)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
NoticeMessages(
systemMessage="",
message =twitchUser.userType
)
}
-
AnnounceMessagesis a wrapper composable around the internal SystemMessageBox class
-
Composable function meant to display a system level event sent from the Twitch IRC servers. Read more about the USERNOTICE tags of announcement
-
UI demonstration with code below:
![Announcement](https://private-user-images.githubusercontent.com/47083513/324029214-8c93c270-0115-49b4-8f23-3d10dc5c7e6b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwMjkyMTQtOGM5M2MyNzAtMDExNS00OWI0LThmMjMtM2QxMGRjNWM3ZTZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg2NmNjZmMzNmE0YWRiMmVjZmVhNzkwMmZkOTcyOWFkYzI3Y2JmMTJiN2Q3MTk1YjY5NmUyYjhhNDVhNjEyOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.RpeDlJi6xxNORyyM0_QPvMbmHV2MfjqhkzIuqvfY3Go)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
AnnouncementMessages(
message = "${twitchUser.displayName}: ${twitchUser.systemMessage}"
)
}
-
ReSubMessage is a wrapper composable around the internal SystemMessageBox class
-
Composable function meant to display a message to the user indicating a reSub event has occurred
-
UI demonstration with code below:
![ReSubMessage](https://private-user-images.githubusercontent.com/47083513/324029901-ea4fa1c7-9b9f-4694-93dc-293d5ca962fa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwMjk5MDEtZWE0ZmExYzctOWI5Zi00Njk0LTkzZGMtMjkzZDVjYTk2MmZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2MzllNDczZmE0MTRkOWI2MDUzMDVlMWI5OWUyZmU4ZDhmZWVkOGViOTYyODE1YzY0OTRmMWRmMWNkNTk3MTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Lo9gx6arZ_uZlzXvOlkuPkhxz33jpV34EcZZL8YH9sc)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
ReSubMessage(
systemMessage = twitchUser.systemMessage,
message = twitchUser.userType,
)
}
-
SubMessages is a wrapper composable around the internal SystemMessageBox class
-
Composable function meant to display a message to the user once a USERNOTICE tags of sub
-
UI demonstration with code below:
![SubMessages](https://private-user-images.githubusercontent.com/47083513/324030505-b43a461c-5194-4256-ac75-ef7f5369464f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwMzA1MDUtYjQzYTQ2MWMtNTE5NC00MjU2LWFjNzUtZWY3ZjUzNjk0NjRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyMjBmMWUyYjhiYmYwYTVmMTc1MWEzYWJlMzNkN2EzODM5YTExMDZhOTZmMmUwYmNiMGNhNTU5YWJhNjE2MDQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ti8bmDqaALnrQG_-snkn4RF8CQc4KS-WPwfYPr0_zWM)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
SubMessages(
systemMessage = twitchUser.systemMessage,
message = twitchUser.userType,
)
}
-
AnonGiftMessagesis a wrapper composable around the internal SystemMessageBox class
-
Composable function meant to display a message to the user once a USERNOTICE tags of submysterygift
-
UI demonstration with code below:
![AnonGiftMessages](https://private-user-images.githubusercontent.com/47083513/324033092-27c358cb-2edc-4d46-a7ca-d920075dfb33.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwMzMwOTItMjdjMzU4Y2ItMmVkYy00ZDQ2LWE3Y2EtZDkyMDA3NWRmYjMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlkODc0YWZiODRlMThhMTYwMjIwMmVjNDljMTZlOTM2Yjk4YmY3Y2MzZWJmODVkNzU3NTgyZjk5MGViYzMyYTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.QuZrbkE40pJzMWyTPK3k0U1gwLWYMGz-Q053uUpjoaA)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
AnonGiftMessages(
message = twitchUser.userType,
systemMessage = twitchUser.systemMessage
)
}
-
GiftSubMessages is a wrapper composable around the internal SystemMessageBox class
-
Composable function meant to display a message to the user once a USERNOTICE tags of subgift
-
UI demonstration with code below:
![AnonGiftMessages](https://private-user-images.githubusercontent.com/47083513/324040809-531fe6d0-ff93-4765-98f3-3d40de8daa83.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwNDA4MDktNTMxZmU2ZDAtZmY5My00NzY1LTk4ZjMtM2Q0MGRlOGRhYTgzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc0MDEwZjFkYjkwYWY2MWIyY2ZmNDFhN2QzMWFmYzU5ZGVkMDcxMjUxZDA0NDIxMjhjYjVkNmQwYWE0OTQ4OWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.XCAT_amPgwdzjxGeA-Y99sSfyN8CusvoBusORJTlVRs)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
GiftSubMessages(
message = twitchUser.userType,
systemMessage = twitchUser.systemMessage
)
}
-
Composable function meant to display a message indicating that we have successfully joined the chat room. This composable is shown after the Joining a Chat Room process
-
UI demonstration with code below:
![JoinMessage](https://private-user-images.githubusercontent.com/47083513/324033556-fd857696-4b6e-410e-949e-bd388dd0f696.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjQwMzM1NTYtZmQ4NTc2OTYtNGI2ZS00MTBlLTk0OWUtYmQzODhkZDBmNjk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRmYjQ5MzBiOTNjOGQxMTYxYzhkYzJhMDkyZmZkMDg2NjMwMzZjMTk4YzYzZjBmODAwOTg0MzM4Mjc1ZjRmZjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.IxMTYZ0ZlhvtTbsp4WY7IVZA3TPCDbm6Io8vfumdJcs)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
JoinMessage(
message = twitchUser.userType ?:""
)
}
-
ChatErrorMessage is a composable meant to signify to the user that an error has occurred relating to chat, ie, the intended action has not taken place
-
UI demonstration with code below:
![chatErrorMessage](https://private-user-images.githubusercontent.com/47083513/328602639-ac969780-8a28-445d-8877-b583e4c9953f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTg0MTEsIm5iZiI6MTczOTYxODExMSwicGF0aCI6Ii80NzA4MzUxMy8zMjg2MDI2MzktYWM5Njk3ODAtOGEyOC00NDVkLTg4NzctYjU4M2U0Yzk5NTNmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDExMTUxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA5ZWZlOWI0MDZjODBlNDUzMjBiOGYzOGQyM2I0MDY0YWNiNDBhZjdhODcyYWU5NDMyNDkwMDYxM2I3YTk4NjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.d0P1ifjWetXapibndQTb8dw5jAgqS6pmWTdJfhe4XSk)
val titleFontSize = MaterialTheme.typography.headlineMedium.fontSize
val messageFontSize = MaterialTheme.typography.headlineSmall.fontSize
val chatScope = remember(){ ChatScope(titleFontSize,messageFontSize) }
with(chatScope){
ChatErrorMessage(
message = twitchChatMessage.userType ?:""
)
}
/**
* ChatScope contains all the System level(sent from the Twitch servers) chat messages used throughout the application. ChatScope
* contains 8 properties
*
* @param titleFontSize a [TextUnit] that is used to determine the the size of the messageType parameter used in all the composables
* @param messageFontSize a [TextUnit] that is used to determine the the size of the message parameter used in all the composables
*
* @property NoticeMessages
* @property AnnouncementMessages
* @property ReSubMessage
* @property SubMessages
* @property GiftSubMessages
* @property AnonGiftMessages
* @property JoinMessage
* @property ChatErrorMessage
* */
@Stable
class ChatScope(
private val titleFontSize: TextUnit,
private val messageFontSize:TextUnit
) {
/**
* NoticeMessages is a wrapper composable around the [SystemMessageBox]
* - Composable function meant to display a system level event sent from the Twitch IRC servers. Read more about the
* [NOTICE](https://dev.twitch.tv/docs/irc/commands/#notice) process
* */
@Composable
fun NoticeMessages(
systemMessage: String?,
message: String?
){
SystemMessageBox(
systemMessage =systemMessage?:"",
message=message?:"",
painter=painterResource(id = R.drawable.baseline_location_on_24),
color= Color.Yellow,
messageType = "Alert!"
)
}
/**
* AnnouncementMessages is a wrapper composable around the [SystemMessageBox]
* - Composable function meant to display a message to the user once a
* [USERNOTICE tags](https://dev.twitch.tv/docs/irc/tags/#usernotice-tags) of ***announcement***
* */
@Composable
fun AnnouncementMessages(
message: String?
){
SystemMessageBox(
systemMessage ="",
message=message?:"",
painter=painterResource(id = R.drawable.baseline_announcement_24),
color= Color.Blue,
messageType = "Announcement"
)
}
/**
* ReSubMessage is a wrapper composable around the [SystemMessageBox]
* - Composable function meant to display a message to the user indicating a reSub event has occurred
* */
@Composable
fun ReSubMessage(
systemMessage: String?,
message: String?
){
SystemMessageBox(
systemMessage =systemMessage?:"",
message=message?:"",
painter=painterResource(id = R.drawable.baseline_new_releases_24),
color= MaterialTheme.colorScheme.secondary,
messageType = "Re-Sub"
)
}
/**
* SubMessages is a wrapper composable around the [SystemMessageBox]
* - Composable function meant to display a message to the user once a [USERNOTICE tags](https://dev.twitch.tv/docs/irc/tags/#usernotice-tags) of ***sub***
* */
@Composable
fun SubMessages(
systemMessage: String?,
message: String?
){
SystemMessageBox(
systemMessage =systemMessage?:"",
message=message?:"",
painter=painterResource(id = R.drawable.baseline_star_outline),
color= MaterialTheme.colorScheme.secondary,
messageType = "Sub"
)
}
/**
* GiftSubMessages is a wrapper composable around the [SystemMessageBox]
* - Composable function meant to display a message to the user once a [USERNOTICE tags](https://dev.twitch.tv/docs/irc/tags/#usernotice-tags) of ***subgift***
* */
@Composable
fun GiftSubMessages(
systemMessage: String?,
message: String?
){
SystemMessageBox(
systemMessage =systemMessage?:"",
message=message?:"",
painter=painterResource(id = R.drawable.gift),
color= MaterialTheme.colorScheme.secondary,
messageType = "Gift Sub"
)
}
/**
* AnonGiftMessages is a wrapper composable around the [SystemMessageBox]
- Composable function meant to display a message to the user once a [USERNOTICE tags](https://dev.twitch.tv/docs/irc/tags/#usernotice-tags) of ***submysterygift***
* */
@Composable
fun AnonGiftMessages(
systemMessage: String?,
message: String?
){
SystemMessageBox(
systemMessage =systemMessage?:"",
message=message?:"",
painter=painterResource(id = R.drawable.baseline_question_mark_24),
color= MaterialTheme.colorScheme.secondary,
messageType = "Anonymous gift sub"
)
}
/**
* Composable function meant to display a message indicating that we have successfully joined the chat room. This composable
* is shown after the [Joining a Chat Room](https://dev.twitch.tv/docs/irc/join-chat-room/) process
*
* @param message String personal message sent from the user. Meant to be displayed to the rest of chat
* */
@Composable
fun JoinMessage(message: String) {
SimpleText(message = message)
}
/**
* ChatErrorMessage is a composable meant to signify to the user that an error has occurred relating to chat, ie, the intended
* action has not taken place
*
* @param message a String meant to display the error information to the user
* */
@Composable
fun ChatErrorMessage(
message:String
){
val sideFade = Brush.horizontalGradient(
listOf(
Color.Red, Color.Red.copy(alpha = 0.8f), Color.Red.copy(alpha = 0.6f),
Color.Red.copy(alpha = 0.4f), Color.Red.copy(alpha = 0.2f), Color.Red.copy(alpha = 0.0f)
),
startX = 0.0f,
endX = 130.0f
)
Box(
modifier = Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.primary)
){
Spacer(modifier = Modifier.align(Alignment.CenterStart)
.width(130.dp)
.fadingEdge(sideFade)
.clip(RoundedCornerShape(4.dp))
.background(Color.Red)
.height(80.dp)
)
Row(){
Spacer(modifier = Modifier
.height(80.dp)
)
Spacer(modifier = Modifier
.width(17.dp)
)
Column(
modifier = Modifier
.fillMaxWidth()
) {
Row(verticalAlignment = Alignment.CenterVertically){
Text("Error", color = MaterialTheme.colorScheme.onPrimary,fontSize=titleFontSize)
Spacer(modifier = Modifier
.width(6.dp)
)
Icon(
painter = painterResource(id = R.drawable.error_outline_24),
contentDescription = "Chat error",
tint = Color.Red,
modifier = Modifier.size(20.dp)
)
}
Text(message, color = MaterialTheme.colorScheme.onPrimary,fontSize=messageFontSize)
}
}
}
}
/**
* SystemMessageBox is a private [Box] composable that is used internally to give the System level chat messages their gradient styling
*
* @param systemMessage a String representing the message that is sent from the Twitch IRC servers
* @param message a String representing the message sent from the individual user
* @param messageType A String representing the type of system level chat being sent
* @param painter the [Painter] value shown in an icon to the right of [messageType]
* @param color the color of the Gradient
* */
@Composable
private fun SystemMessageBox(
systemMessage:String,
message:String,
messageType: String,
painter: Painter,
color: Color,
){
var height by remember { mutableStateOf(80.dp) }
val localDensity = LocalDensity.current
val sideFade = Brush.horizontalGradient(
listOf(
color, color.copy(alpha = 0.8f), color.copy(alpha = 0.6f),
color.copy(alpha = 0.4f), color.copy(alpha = 0.2f), color.copy(alpha = 0.0f)
),
startX = 0.0f,
endX = 130.0f
)
Box(
modifier = Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.primary)
){
Spacer(modifier = Modifier.align(Alignment.CenterStart)
.width(130.dp)
.fadingEdge(sideFade)
.clip(RoundedCornerShape(4.dp))
.background(color)
.height(height)
)
Row(){
Spacer(modifier = Modifier
.height(height)
)
Spacer(modifier = Modifier
.width(17.dp)
)
Column(
modifier = Modifier
.fillMaxWidth()
) {
Row(verticalAlignment = Alignment.CenterVertically){
//todo: this should be message type
Text("$messageType", color = MaterialTheme.colorScheme.onPrimary,fontSize=titleFontSize)
Spacer(modifier = Modifier
.width(6.dp)
)
Icon(
painter = painter,
contentDescription = messageType,
tint = color,
modifier = Modifier.size(25.dp)
)
}
Text(
//todo: this should be message type
"$systemMessage $message",
color = MaterialTheme.colorScheme.onPrimary,
fontSize=messageFontSize,
modifier = Modifier.onGloballyPositioned {
height = with(localDensity) { it.size.height.toDp() + 30.dp }
}
)
}
}
}
}
/**
* SimpleText is a simple composable used to give the styling of [JoinMessage]
*
* @param message a String representing a large amount of information
* */
@Composable
private fun SimpleText(message: String){
Text(
message,
fontSize = titleFontSize,
color = MaterialTheme.colorScheme.onPrimary,
modifier = Modifier.padding(start = 5.dp)
)
}
}