Skip to content

Commit

Permalink
Merge branch 'feature/ONE-3599-history-warning-status' into 'main'
Browse files Browse the repository at this point in the history
[ONE-3599] Added history warning status and updated history action icon

Closes ONE-3599

See merge request procivis/one/one-react-native-components!157
  • Loading branch information
procivisAG committed Oct 17, 2024
2 parents a867df9 + d2b137e commit 9831ed2
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 44 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@procivis/one-react-native-components",
"version": "0.1.60",
"version": "0.1.61",
"author": "Procivis AG (https://procivis.ch)",
"license": "Apache-2.0",
"description": "Common Procivis ONE UI components for react-native",
Expand Down
111 changes: 69 additions & 42 deletions src/icons/history.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { FC } from 'react';
import { StyleSheet, View, ViewProps } from 'react-native';
import { StyleProp, StyleSheet, View, ViewProps, ViewStyle } from 'react-native';
import Svg, { G, Path, Rect, SvgProps } from 'react-native-svg';

import { useAppColorScheme } from '../theme/color-scheme-context';
import { CredentialWarningIcon } from './credential';

// https://www.figma.com/file/52qDYWUMjXAGre1dcnz5bz/Procivis-One-Wallet?node-id=454-99608
const HistoryShareIcon: FC<SvgProps> = (props) => {
Expand Down Expand Up @@ -229,6 +230,7 @@ const HistoryStatusIndicatorIcon: FC<SvgProps> = (props) => {

export enum HistoryStatusIconType {
Success,
Warning,
Error,
Delete,
Suspend,
Expand All @@ -246,6 +248,9 @@ export const HistoryStatusIcon: FC<HistoryStatusIconProps> = ({ type, ...props }
case HistoryStatusIconType.Success:
StatusIcon = HistoryStatusAcceptedIcon;
break;
case HistoryStatusIconType.Warning:
StatusIcon = CredentialWarningIcon;
break;
case HistoryStatusIconType.Error:
StatusIcon = HistoryStatusErrorIcon;
break;
Expand Down Expand Up @@ -281,53 +286,75 @@ export enum HistoryActionIconType {
Error,
}

export interface HistoryActionIconProps extends ViewProps {
type: HistoryActionIconType;
}
export type HistoryActionIconProps = ViewProps &
(
| {
type: HistoryActionIconType;
}
| {
statusIcon: HistoryStatusIconType;
TypeIcon: FC<SvgProps>;
}
);

export const HistoryActionIcon: FC<HistoryActionIconProps> = ({ type, style, ...props }) => {
export const HistoryActionIcon: FC<HistoryActionIconProps> = (props) => {
let TypeIcon = HistoryShareIcon;
switch (type) {
case HistoryActionIconType.Issue:
TypeIcon = HistoryIssueIcon;
break;
case HistoryActionIconType.IssueReject:
TypeIcon = HistoryIssueIcon;
break;
case HistoryActionIconType.Revoke:
TypeIcon = HistoryRevokeIcon;
break;
case HistoryActionIconType.Revalidate:
case HistoryActionIconType.Suspend:
case HistoryActionIconType.SuspendTemporary:
TypeIcon = HistorySuspendIcon;
break;
}

let statusIcon = HistoryStatusIconType.Success;
switch (type) {
case HistoryActionIconType.IssueReject:
statusIcon = HistoryStatusIconType.Error;
break;
case HistoryActionIconType.ShareReject:
case HistoryActionIconType.Error:
case HistoryActionIconType.Revoke:
case HistoryActionIconType.RequestReject:
statusIcon = HistoryStatusIconType.Error;
break;
case HistoryActionIconType.Suspend:
statusIcon = HistoryStatusIconType.Suspend;
break;
case HistoryActionIconType.SuspendTemporary:
statusIcon = HistoryStatusIconType.SuspendTemporary;
break;
case HistoryActionIconType.RequestDeleted:
statusIcon = HistoryStatusIconType.Delete;
break;
let style: StyleProp<ViewStyle>;
let viewProps: ViewProps;

if ('type' in props) {
const { type, style: styleProp, ...otherProps } = props;
style = styleProp;
viewProps = otherProps;

switch (type) {
case HistoryActionIconType.Issue:
TypeIcon = HistoryIssueIcon;
break;
case HistoryActionIconType.IssueReject:
TypeIcon = HistoryIssueIcon;
break;
case HistoryActionIconType.Revoke:
TypeIcon = HistoryRevokeIcon;
break;
case HistoryActionIconType.Revalidate:
case HistoryActionIconType.Suspend:
case HistoryActionIconType.SuspendTemporary:
TypeIcon = HistorySuspendIcon;
break;
}

switch (type) {
case HistoryActionIconType.IssueReject:
statusIcon = HistoryStatusIconType.Error;
break;
case HistoryActionIconType.ShareReject:
case HistoryActionIconType.Error:
case HistoryActionIconType.Revoke:
case HistoryActionIconType.RequestReject:
statusIcon = HistoryStatusIconType.Error;
break;
case HistoryActionIconType.Suspend:
statusIcon = HistoryStatusIconType.Suspend;
break;
case HistoryActionIconType.SuspendTemporary:
statusIcon = HistoryStatusIconType.SuspendTemporary;
break;
case HistoryActionIconType.RequestDeleted:
statusIcon = HistoryStatusIconType.Delete;
break;
}
} else {
const { TypeIcon: TypeIconProp, statusIcon: statusIconProp, style: styleProp, ...otherProps } = props;
TypeIcon = TypeIconProp;
statusIcon = statusIconProp;
style = styleProp;
viewProps = otherProps;
}

return (
<View style={[styles.wrapper, style]} {...props}>
<View style={[styles.wrapper, style]} {...viewProps}>
<TypeIcon style={styles.round} />
<HistoryStatusIcon style={styles.status} type={statusIcon} />
</View>
Expand Down
1 change: 0 additions & 1 deletion src/nerd-view/nerd-mode-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ const NerdModeItem: FunctionComponent<NerdModeItemProps> = ({

setTimeout(() => {
valueViewRef.current?.measure((x, y, w, h, px, py) => {
console.log(h, py, scrollOffset.value);
expandedView.value = {
expandedAtOffset: isSingleLine ? 0 : scrollOffset.value,
viewHeight: isSingleLine ? 0 : h - 2 * CONTAINER_PADDING,
Expand Down

0 comments on commit 9831ed2

Please sign in to comment.