-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finised adding Ciontek printer support
- Loading branch information
1 parent
aa74fc2
commit 85f20cb
Showing
8 changed files
with
157 additions
and
84 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 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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import {NativeModules, Alert} from 'react-native'; | ||
import moment from 'moment'; | ||
|
||
export const printBitcoinize = async ( | ||
description, | ||
timestamp, | ||
ispaid, | ||
payment_hash, | ||
amt, | ||
) => { | ||
try { | ||
await NativeModules.PrintModule.printText(description, 32); | ||
await NativeModules.PrintModule.paperOut(24); | ||
|
||
await NativeModules.PrintModule.printText('Payment made in Bitcoin', 24); | ||
await NativeModules.PrintModule.paperOut(24); | ||
|
||
await NativeModules.PrintModule.printText( | ||
moment(timestamp * 1000).format('DD/MM/YY HH:mm:ss'), | ||
24, | ||
); | ||
await NativeModules.PrintModule.paperOut(24); | ||
|
||
await NativeModules.PrintModule.printText( | ||
amt + ' sats ' + (ispaid ? '(PAID)' : '(PENDING)'), | ||
32, | ||
); | ||
await NativeModules.PrintModule.paperOut(24); | ||
|
||
await NativeModules.PrintModule.printText(payment_hash, 24); | ||
await NativeModules.PrintModule.paperOut(24); | ||
await NativeModules.PrintModule.printQRCode( | ||
JSON.stringify({payment_hash: payment_hash}), | ||
400, | ||
400, | ||
); | ||
|
||
await NativeModules.PrintModule.paperOut(100); | ||
} catch (e) { | ||
Alert.alert('Error', 'There was an error when printing ' + e.message, [ | ||
{text: 'OK', onPress: () => console.log('OK Pressed')}, | ||
]); | ||
} | ||
}; | ||
|
||
export const printCiontek = async ( | ||
description, | ||
timestamp, | ||
ispaid, | ||
payment_hash, | ||
amt, | ||
) => { | ||
try { | ||
await NativeModules.PrintModule.printTextCiontek(description, 32); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
|
||
await NativeModules.PrintModule.printTextCiontek( | ||
'Payment made in Bitcoin', | ||
24, | ||
); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
|
||
await NativeModules.PrintModule.printTextCiontek( | ||
moment(timestamp * 1000).format('DD/MM/YY HH:mm:ss'), | ||
24, | ||
); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
|
||
await NativeModules.PrintModule.printTextCiontek( | ||
amt + ' sats ' + (ispaid ? '(PAID)' : '(PENDING)'), | ||
32, | ||
); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
|
||
await NativeModules.PrintModule.printTextCiontek(payment_hash, 24); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
await NativeModules.PrintModule.printQRCodeCiontek( | ||
JSON.stringify({payment_hash: payment_hash}), | ||
360, | ||
360, | ||
); | ||
|
||
await NativeModules.PrintModule.paperOutCiontek(); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
await NativeModules.PrintModule.paperOutCiontek(); | ||
} catch (e) { | ||
Alert.alert('Error', 'There was an error when printing ' + e.message, [ | ||
{text: 'OK', onPress: () => console.log('OK Pressed')}, | ||
]); | ||
} | ||
}; |
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