Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement scrollable message #394

Merged
merged 5 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/css/components/_appstore-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
flex-direction: column;
}

::-webkit-scrollbar {
div::-webkit-scrollbar {
display: none;
}

Expand Down
114 changes: 114 additions & 0 deletions src/css/components/_scrollable_message.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
.scrollableMessageOverlay {
position : fixed;
top : 0;
left : 0;
right : 0;
bottom : 0;
background-color : rgba(0, 0, 0, 0.75);
width: $master-width;
height: $master-height;
margin: 25px;
z-index:1001;
}

.scrollableMessageModal {
position: absolute;
top: 50%;
left: 50%;
right: auto;
bottom: auto;
margin-right: -50%;
@include transform(translate(-50%, -50%));
border: 1px solid #ccc;
overflow: hidden;
border-radius: 4px;
outline: none;
padding: 20px;
width: 85%;
height: calc(#{$master-height} / 5 * 4);
}

.scrollableMessage {
@include display(flex);
@include flex-direction(column);
overflow: hidden;
height: calc(#{$master-height} / 5 * 4);
}

.scrollableTitle {
text-align: center;

p {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}

.scrollableBody {
@include display(flex);
@include flex-direction(row);
height: 80%;
max-height: 80%;
}

.scrollableMessage-buttons {
@include display(flex);
@include flex-direction(column);
width: 30%;
padding-right: 16px;
}

.scrollableMessage-button {
width: 100%;
text-align: center;
border-radius: 8px;
border-width: 0.154px;
border-style: solid;
margin: 4px 4px;
height: 40px;
padding: 1px 4px;

@include display(flex);
@include flex-direction(row);
@include align-items(center);
@include justify-content(left);

.soft-button-image {
max-height: 36px;
display: flex;
align-items: center;
padding: 5px;
}

.soft-button-image-static {
max-height: 36px;
max-width: 100%;
min-width: 36px;
padding: 5px;

div svg {
max-height: 36px;
}
}

p {
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
}

.scrollableText {
width: 70%;
max-width: 70%;
height: 100%;

p {
height: 100%;
overflow-y: auto;
word-wrap: normal;
white-space: pre-wrap;
}
}
2 changes: 1 addition & 1 deletion src/css/components/_v-scroll-menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
overflow-y: scroll;
}

::-webkit-scrollbar {
div::-webkit-scrollbar {
display: none;
}
1 change: 1 addition & 0 deletions src/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
@import 'components/app-services-nav';
@import 'components/appstore-menu';
@import 'components/keyboard';
@import 'components/scrollable_message';

19 changes: 19 additions & 0 deletions src/js/AppHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {resetShowAppMenu} from './actions'
import { connect } from 'react-redux'
import { Link } from 'react-router-dom';
import uiController from './Controllers/UIController'
import ScrollableMessage from './ScrollableMessage';

import {ReactComponent as IconMenu} from '../img/icons/icon-menu.svg'
import {ReactComponent as IconCart} from '../img/icons/icon-cart.svg'
Expand Down Expand Up @@ -48,6 +49,7 @@ class AppHeader extends React.Component {
constructor(props) {
super(props);
this.closeModal = this.closeModal.bind(this);
this.closeScrollable = this.closeScrollable.bind(this);
}

closeModal() {
Expand All @@ -58,6 +60,11 @@ class AppHeader extends React.Component {
}
}

closeScrollable() {
uiController.onCloseScrollableMessage(this.props.scrollableMessageMsgId,
this.props.scrollableMessageAppId, this.props.activeApp);
}

getColorScheme() {
if (this.props.colorScheme) {
var redInt = this.props.colorScheme.red;
Expand Down Expand Up @@ -121,6 +128,18 @@ class AppHeader extends React.Component {
>
{alertHtml}
</Modal>
<Modal
isOpen={this.props.showScrollableMessage}
className={'app-body scrollableMessageModal'}
overlayClassName={`${themeClass} scrollableMessageOverlay`}
contentLabel="Example Modal"
onRequestClose={this.closeScrollable}
>
<ScrollableMessage theme={this.props.theme}
body={this.props.scrollableMessageBody}
buttons={this.props.softButtons}
appName={this.props.scrollableMessageAppName}/>
</Modal>
</div>

)
Expand Down
11 changes: 11 additions & 0 deletions src/js/Controllers/DisplayCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ let textWithGraphicCapabilities = {
textField("mainField3"),
textField("mainField4"),
textField("templateTitle", 50),
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -112,6 +113,7 @@ let textbuttonsWithGraphicCapabilities = {
"displayType": "SDL_GENERIC",
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -181,6 +183,7 @@ let capabilities = {
textField("mediaClock"),
textField("mediaTrack"),
textField("templateTitle", 50),
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -258,6 +261,7 @@ let capabilities = {
textField("mainField3"),
textField("mainField4"),
textField("templateTitle", 50),
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -314,6 +318,7 @@ let capabilities = {
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("templateTitle", 50),
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand All @@ -335,6 +340,7 @@ let capabilities = {
"displayType": "SDL_GENERIC",
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -391,6 +397,7 @@ let capabilities = {
"displayType": "SDL_GENERIC",
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -448,6 +455,7 @@ let capabilities = {
"displayType": "SDL_GENERIC",
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -490,6 +498,7 @@ let capabilities = {
"displayType": "SDL_GENERIC",
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -545,6 +554,7 @@ let capabilities = {
"displayType": "SDL_GENERIC",
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down Expand Up @@ -601,6 +611,7 @@ let capabilities = {
"displayName": "GENERIC_DISPLAY",
"textFields": [
textField("templateTitle", 50),
textField("scrollableMessageBody", 44, 15),
textField("alertText1"),
textField("alertText2"),
textField("alertText3"),
Expand Down
23 changes: 23 additions & 0 deletions src/js/Controllers/RpcFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@ class RpcFactory {
}
})
}
static ScrollableMessageResponse(msgID) {
return ({
jsonrpc: '2.0',
id: msgID,
result: {
code: 0,
method: 'UI.ScrollableMessage'
}
});
}
static ScrollableMessageAbortedResponse(rpcID) {
return ({
"jsonrpc": "2.0",
"id": rpcID,
"error": {
"code": 5,
"message": "The Scrollable Message was cancelled",
"data": {
"method": "UI.ScrollableMessage"
}
}
})
}
static SubtleAlertResponse(rpcID) {
return ({
"jsonrpc": "2.0",
Expand Down
Loading