-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(add): add print helpers and pairing printer method
- Loading branch information
Showing
31 changed files
with
746 additions
and
207 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { memo } from 'react'; | ||
import { Text, View } from 'react-native'; | ||
import { | ||
type PrinterStatusResponse, | ||
PrinterConstants, | ||
} from 'react-native-esc-pos-printer'; | ||
import { styles } from './styles'; | ||
|
||
interface PrinterStatusProps { | ||
status: PrinterStatusResponse; | ||
} | ||
|
||
export const PrinterStatus = memo(({ status }: PrinterStatusProps) => { | ||
const { connection, online, coverOpen, paper } = status; | ||
|
||
const renderRow = ( | ||
title: string, | ||
isGreenIndicator: boolean, | ||
isYellowIndicator?: boolean | ||
) => { | ||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.text}>{title}</Text> | ||
<View | ||
style={[ | ||
styles.indicator, | ||
isGreenIndicator ? styles.indicatorGreen : styles.indicatorRed, | ||
isYellowIndicator && styles.indicatorYellow, | ||
]} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
return ( | ||
<View style={[styles.container, styles.contentContainer]}> | ||
{renderRow('Connected', connection.statusCode === PrinterConstants.TRUE)} | ||
{renderRow('Online', online.statusCode === PrinterConstants.TRUE)} | ||
{renderRow('Cover open', coverOpen.statusCode === PrinterConstants.FALSE)} | ||
{renderRow( | ||
'Paper', | ||
paper.statusCode === PrinterConstants.PAPER_OK, | ||
paper.statusCode === PrinterConstants.PAPER_NEAR_END | ||
)} | ||
</View> | ||
); | ||
}); |
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 @@ | ||
export { PrinterStatus } from './PrinterStatus'; |
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,31 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
export const styles = StyleSheet.create({ | ||
contentContainer: { | ||
justifyContent: 'space-around', | ||
}, | ||
indicator: { | ||
width: 6, | ||
height: 6, | ||
borderRadius: 5, | ||
marginRight: 15, | ||
marginLeft: 3, | ||
}, | ||
indicatorGreen: { | ||
backgroundColor: 'green', | ||
}, | ||
indicatorRed: { | ||
backgroundColor: 'red', | ||
}, | ||
indicatorYellow: { | ||
backgroundColor: 'yellow', | ||
}, | ||
container: { | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}, | ||
text: { | ||
fontSize: 14, | ||
color: '#000', | ||
}, | ||
}); |
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
Oops, something went wrong.