Skip to content

Commit

Permalink
[Fl-3809] Troika parser visual fixes (#3614)
Browse files Browse the repository at this point in the history
Co-authored-by: あく <[email protected]>
  • Loading branch information
Astrrra and skotopes authored Apr 24, 2024
1 parent 34abaa7 commit 1559ee6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion applications/main/nfc/api/mosgortrans/mosgortrans_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ bool mosgortrans_parse_transport_block(const MfClassicBlock* block, FuriString*

if(data_block.valid_from_date == 0 || data_block.valid_to_date == 0) {
furi_string_cat(result, "\e#No ticket");
return true;
return false;
}
//remaining_trips
furi_string_cat_printf(result, "Trips: %d\n", data_block.total_trips);
Expand Down
31 changes: 23 additions & 8 deletions applications/main/nfc/plugins/supported_cards/troika.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ static const MfClassicKeyPair troika_4k_keys[] = {
{.a = 0xBB52F8CCE07F, .b = 0x6B6119752C70}, //40
};

static void troika_render_section_header(
FuriString* str,
const char* name,
uint8_t prefix_separator_cnt,
uint8_t suffix_separator_cnt) {
for(uint8_t i = 0; i < prefix_separator_cnt; i++) {
furi_string_cat_printf(str, ":");
}
furi_string_cat_printf(str, "[ %s ]", name);
for(uint8_t i = 0; i < suffix_separator_cnt; i++) {
furi_string_cat_printf(str, ":");
}
}

static bool troika_get_card_config(TroikaCardConfig* config, MfClassicType type) {
bool success = true;

Expand Down Expand Up @@ -204,18 +218,19 @@ static bool troika_parse(const NfcDevice* device, FuriString* parsed_data) {
bool result3 = mosgortrans_parse_transport_block(&data->block[16], tat_result);

furi_string_cat_printf(parsed_data, "\e#Troyka card\n");
if(result1) {
furi_string_cat_printf(
parsed_data, "\e#Metro\n%s\n", furi_string_get_cstr(metro_result));
if(result1 && !furi_string_empty(metro_result)) {
troika_render_section_header(parsed_data, "Metro", 22, 21);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(metro_result));
}

if(result2) {
furi_string_cat_printf(
parsed_data, "\n\e#Ediniy\n%s\n", furi_string_get_cstr(ground_result));
if(result2 && !furi_string_empty(ground_result)) {
troika_render_section_header(parsed_data, "Ediny", 22, 22);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(ground_result));
}

if(result3) {
furi_string_cat_printf(parsed_data, "\n\e#TAT\n%s", furi_string_get_cstr(tat_result));
if(result3 && !furi_string_empty(tat_result)) {
troika_render_section_header(parsed_data, "TAT", 24, 23);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(tat_result));
}

furi_string_free(tat_result);
Expand Down

0 comments on commit 1559ee6

Please sign in to comment.