flipperzero-firmware/applications/nfc/views/bank_card.c
gornekich 49af516ec7
[FL-1547], [FL-1500] NFC app v1 (#593)
* nfc: remove mifare read debug view and scene
* nfc: change mifare ultralight data structure
* mifare_ultralight: add more commands
* nfc: add emulate mifare ul scene
* nfc: rework data structures, remove debug scenes and views
* nfc: add read emv scenes
* nfc: mifare emulation wip
* nfc cli: increase detecting time
* nfc: save nfc files with new format
* nfc: store Mifare Ultralight
* nfc: start loading mifare ultralight
* nfc: add delete scenes
* nfc: add edit UID and name
* nfc: finish parsing uid and mifare ul data
* nfc: delete success fix
* gui_widget: introduce GuiWidget
* gui_widget: add string element
* gui_widget: add button element
* gui_widget: move free elements into gui_widget
* nfc: rework info scene with GuiWidget
* nfc: rework device info scene
* nfc: rework delete scene gui
* nfc: add compatible script support
* nfc: rework emv reading scenes
* nfc: rework bank card save
* nfc: add bank card custom view
* gui_widget: add icon element
* nfc: add icon to bank card
* nfc: start worker after switching view

Co-authored-by: あく <alleteam@gmail.com>
2021-07-22 09:05:07 +03:00

66 lines
2.0 KiB
C
Executable File

#include "bank_card.h"
#include "../gui_widget/gui_widget.h"
#include <m-string.h>
struct BankCard {
GuiWidget* widget;
};
BankCard* bank_card_alloc() {
BankCard* bank_card = furi_alloc(sizeof(BankCard));
bank_card->widget = gui_widget_alloc();
return bank_card;
}
void bank_card_free(BankCard* bank_card) {
furi_assert(bank_card);
gui_widget_free(bank_card->widget);
free(bank_card);
}
View* bank_card_get_view(BankCard* bank_card) {
furi_assert(bank_card);
return gui_widget_get_view(bank_card->widget);
}
void bank_card_clear(BankCard* bank_card) {
furi_assert(bank_card);
gui_widget_clear(bank_card->widget);
}
void bank_card_set_name(BankCard* bank_card, char* name) {
furi_assert(bank_card);
furi_assert(name);
gui_widget_add_string_element(
bank_card->widget, 64, 6, AlignCenter, AlignTop, FontSecondary, name);
}
void bank_card_set_number(BankCard* bank_card, uint8_t* number) {
furi_assert(bank_card);
furi_assert(number);
string_t num_str;
string_init(num_str);
for(uint8_t i = 0; i < 8; i += 2) {
string_cat_printf(num_str, "%02X%02X ", number[i], number[i + 1]);
}
gui_widget_add_string_element(
bank_card->widget, 25, 22, AlignLeft, AlignTop, FontSecondary, string_get_cstr(num_str));
gui_widget_add_icon_element(bank_card->widget, 6, 20, &I_EMV_Chip_14x11);
string_clear(num_str);
}
void bank_card_set_exp_date(BankCard* bank_card, uint8_t mon, uint16_t year) {
furi_assert(bank_card);
char exp_date_str[16];
snprintf(exp_date_str, sizeof(exp_date_str), "Exp: %02d/%02d", mon, year % 100);
gui_widget_add_string_element(
bank_card->widget, 122, 54, AlignRight, AlignBottom, FontSecondary, exp_date_str);
}
void bank_card_set_cardholder_name(BankCard* bank_card, char* name) {
furi_assert(bank_card);
furi_assert(name);
gui_widget_add_string_element(
bank_card->widget, 6, 37, AlignLeft, AlignTop, FontSecondary, name);
}