iOS/Sources/Shared/Iconic/MDIMigration.swift

345 lines
13 KiB
Swift

import Foundation
// https://github.com/home-assistant/frontend/blob/92d30a889663008317f7a28faa65beea025f0bfd/src/components/ha-icon.ts
enum MDIMigration {
// MDI Version number is based on number of icons, so count is directly related to version
static let migrationNumber: Int = MaterialDesignIcons.count / 1000 - 5
static func migrate(icon old: String) -> String {
if let updated = renamed[old] {
Current.Log.info("migrating \(old) to \(updated)")
return updated
} else if removed.contains(old) {
Current.Log.info("replacing mdi \(old)")
return MaterialDesignIcons.emoticonSadIcon.name
} else {
return old
}
}
private static let renamed = [
// 5
"account_badge": "badge_account",
"account_badge_alert": "badge_account_alert",
"account_badge_alert_outline": "badge_account_alert_outline",
"account_badge_horizontal": "badge_account_horizontal",
"account_badge_horizontal_outline": "badge_account_horizontal_outline",
"account_badge_outline": "badge_account_outline",
"account_card_details": "card_account_details",
"account_card_details_outline": "card_account_details_outline",
"airplay": "apple_airplay",
"artist": "account_music",
"artist_outline": "account_music_outline",
"audiobook": "book_music",
"azure": "microsoft_azure",
"azure_devops": "microsoft_azure_devops",
"bible": "book_cross",
"bowl": "bowl_mix",
"calendar_repeat": "calendar_sync",
"calendar_repeat_outline": "calendar_sync_outline",
"camcorder_box": "video_box",
"camcorder_box_off": "video_box_off",
"cellphone_settings_variant": "cellphone_cog",
"chart_snakey": "chart_sankey",
"chart_snakey_variant": "chart_sankey_variant",
"coin": "currency_usd_circle",
"coin_outline": "currency_usd_circle_outline",
"coins_outline": "circle_multiple_outline",
"contact_mail": "card_account_mail",
"contact_mail_outline": "card_account_mail_outline",
"contact_phone": "card_account_phone",
"contact_phone_outline": "card_account_phone_outline",
"cowboy": "account_cowboy_hat",
"database_refresh": "database_sync",
"dictionary": "book_alphabet",
"edge": "microsoft_edge",
"edge_legacy": "microsoft_edge_legacy",
"file_document_box": "text_box",
"file_document_box_check_outline": "text_box_check_outline",
"file_document_box_minus": "text_box_minus",
"file_document_box_minus_outline": "text_box_minus_outline",
"file_document_box_multiple": "text_box_multiple",
"file_document_box_multiple_outline": "text_box_multiple_outline",
"file_document_box_outline": "text_box_outline",
"file_document_box_plus": "text_box_plus",
"file_document_box_plus_outline": "text_box_plus_outline",
"file_document_box_remove": "text_box_remove",
"file_document_box_remove_outline": "text_box_remove_outline",
"file_document_box_search": "text_box_search",
"file_document_box_search_outline": "text_box_search_outline",
"file_settings_variant": "file_cog",
"file_settings_variant_outline": "file_cog_outline",
"folder_settings_variant": "folder_cog",
"folder_settings_variant_outline": "folder_cog_outline",
"github_circle": "github",
"google_adwords": "google_ads",
"hackernews": "y_combinator",
"hotel": "bed",
"image_filter": "image_multiple_outline",
"internet_explorer": "microsoft_internet_explorer",
"json": "code_json",
"kotlin": "language_kotlin",
"library_books": "filmstrip_box",
"library_movie": "filmstrip_box_multiple",
"library_music": "music_box_multiple",
"library_music_outline": "music_box_multiple_outline",
"library_video": "play_box_multiple",
"markdown": "language_markdown",
"markdown_outline": "language_markdown_outline",
"message_settings_variant": "message_cog",
"message_settings_variant_outline": "message_cog_outline",
"microsoft_dynamics": "microsoft_dynamics_365",
"network_router": "router_network",
"office": "microsoft_office",
"onedrive": "microsoft_onedrive",
"onenote": "microsoft_onenote",
"outlook": "microsoft_outlook",
"periodic_table_co": "molecule_co",
"periodic_table_co2": "molecule_co2",
"playstation": "sony_playstation",
"pot": "pot_steam",
"ruby": "language_ruby",
"sailing": "sail_boat",
"scooter": "human_scooter",
"selection_mutliple": "selection_multiple",
"settings": "cog",
"settings_box": "cog_box",
"settings_outline": "cog_outline",
"settings_transfer": "cog_transfer",
"settings_transfer_outline": "cog_transfer_outline",
"shield_refresh": "shield_sync",
"shield_refresh_outline": "shield_sync_outline",
"sort_alphabetical": "sort_alphabetical_variant",
"sort_alphabetical_ascending": "sort_alphabetical_ascending_variant",
"sort_alphabetical_descending": "sort_alphabetical_descending_variant",
"sort_numeric": "sort_numeric_variant",
"star_half": "star_half_full",
"storefront": "storefront_outline",
"syllabary_katakana_half_width": "syllabary_katakana_halfwidth",
"textarea": "form_textarea",
"textbox": "form_textbox",
"textbox_lock": "form_textbox_lock",
"textbox_password": "form_textbox_password",
"timer": "timer_outline",
"timer_off": "timer_off_outline",
"towing": "tow_truck",
"visual_studio": "microsoft_visual_studio",
"visual_studio_code": "microsoft_visual_studio_code",
"voice": "account_voice",
"wall_sconce_variant": "wall_sconce_round_variant",
"wii": "nintendo_wii",
"wiiu": "nintendo_wiiu",
"windows": "microsoft_windows",
"windows_classic": "microsoft_windows_classic",
"worker": "account_hard_hat",
"xbox": "microsoft_xbox",
"xbox_controller": "microsoft_xbox_controller",
"xbox_controller_battery_alert": "microsoft_xbox_controller_battery_alert",
"xbox_controller_battery_charging": "microsoft_xbox_controller_battery_charging",
"xbox_controller_battery_empty": "microsoft_xbox_controller_battery_empty",
"xbox_controller_battery_full": "microsoft_xbox_controller_battery_full",
"xbox_controller_battery_low": "microsoft_xbox_controller_battery_low",
"xbox_controller_battery_medium": "microsoft_xbox_controller_battery_medium",
"xbox_controller_battery_unknown": "microsoft_xbox_controller_battery_unknown",
"xbox_controller_menu": "microsoft_xbox_controller_menu",
"xbox_controller_off": "microsoft_xbox_controller_off",
"xbox_controller_view": "microsoft_xbox_controller_view",
"yammer": "microsoft_yammer",
"youtube_creator_studio": "youtube_studio",
// 6
"apple_airplay": "cast_variant",
"application": "application_outline",
"application_cog": "application_cog_outline",
"application_settings": "application_settings_outline",
"bolnisi_cross": "cross_bolnisi",
"boom_gate_up": "boom_gate_arrow_up",
"boom_gate_up_outline": "boom_gate_arrow_up_outline",
"boom_gate_down": "boom_gate_arrow_down",
"boom_gate_down_outline": "boom_gate_arrow_down_outline",
"buddhism": "dharmachakra",
"cellphone_android": "cellphone",
"cellphone_erase": "cellphone_remove",
"cellphone_iphone": "cellphone",
"celtic_cross": "cross_celtic",
"christianity": "cross",
"christianity_outline": "cross_outline",
"do_not_disturb_off": "minus_circle_off",
"do_not_disturb": "minus_circle",
"face": "face_man",
"face_outline": "face_man_outline",
"face_profile_woman": "face_woman_profile",
"face_shimmer": "face_man_shimmer",
"face_shimmer_outline": "face_man_shimmer_outline",
"file_pdf": "file_pdf_box",
"file_pdf_outline": "file_pdf_box",
"file_pdf_box_outline": "file_pdf_box",
"flash_circle": "lightning_bolt_circle",
"floor_lamp_variant": "floor_lamp_torchiere_variant",
"gif": "file_gif_box",
"gradient": "gradient_vertical",
"hand": "hand_front_right",
"hand_left": "hand_back_left",
"hand_right": "hand_back_right",
"hinduism": "om",
"iframe": "application_brackets",
"iframe_outline": "application_brackets_outline",
"iframe_array": "application_array",
"iframe_array_outline": "application_array_outline",
"iframe_braces": "application_braces",
"iframe_braces_outline": "application_braces_outline",
"iframe_parentheses": "application_parentheses",
"iframe_parentheses_outline": "application_parentheses_outline",
"iframe_variable": "application_variable",
"iframe_variable_outline": "application_variable_outline",
"islam": "star_crescent",
"judaism": "star_david",
"laptop_chromebook": "laptop",
"laptop_mac": "laptop",
"laptop_windows": "laptop",
"monitor_clean": "monitor_shimmer",
"pdf_box": "file_pdf_box",
"pharmacy": "mortar_pestle_plus",
"plus_one": "numeric_positive_1",
"poll_box": "chart_box",
"poll_box_outline": "chart_box_outline",
"sparkles": "shimmer",
"tablet_ipad": "tablet",
"teach": "human_male_board",
"television_clean": "television_shimmer",
"text_subject": "text_long",
"twitter_retweet": "repeat_variant",
"voice_off": "account_voice_off",
"xamarian_outline": "xamarian",
// 7
"android-messages": "message-text",
"book-variant-multiple": "bookmark-box-multiple",
"desktop-mac-dashboard": "monitor-dashboard",
"desktop-mac": "monitor",
"diving-scuba": "diving-scuba-mask",
"email-receive-outline": "email-arrow-left-outline",
"email-receive": "email-arrow-left",
"email-send-outline": "email-arrow-right-outline",
"email-send": "email-arrow-right",
"format-textdirection-l-to-r": "format-pilcrow-arrow-right",
"format-textdirection-r-to-l": "format-pilcrow-arrow-left",
"globe-light": "globe-light-outline",
"google-controller-off": "controller-off",
"google-controller": "controller",
"lecturn": "lectern",
"mosque": "mosque-outline",
"receipt-outline": "receipt-text-outline",
"receipt": "receipt-text",
"silo": "silo-outline",
"tablet-android": "tablet",
"text-to-speech-off": "microphone-message-off",
"text-to-speech": "microphone-message",
"timeline-help-outline": "timeline-question-outline",
"timeline-help": "timeline-question",
"vector-point": "vector-point-select",
]
private static let removed = Set([
// 5
"accusoft",
"amazon_drive",
"android_head",
"basecamp",
"beats",
"behance",
"blackberry",
"cisco_webex",
"disqus_outline",
"dribbble",
"dribbble_box",
"etsy",
"eventbrite",
"facebook_box",
"flattr",
"flickr",
"foursquare",
"github_box",
"github_face",
"glassdoor",
"google_adwords",
"google_pages",
"google_physical_web",
"google_plus_box",
"houzz",
"houzz_box",
"instapaper",
"itunes",
"language_python_text",
"lastfm",
"linkedin_box",
"lyft",
"mail_ru",
"mastodon_variant",
"medium",
"meetup",
"mixcloud",
"mixer",
"nfc_off",
"npm_variant",
"npm_variant_outline",
"paypal",
"periscope",
"pinterest_box",
"pocket",
"quicktime",
"shopify",
"slackware",
"square_inc",
"square_inc_cash",
"steam_box",
"strava",
"tor",
"tumblr",
"tumblr_box",
"tumblr_reblog",
"twitter_box",
"twitter_circle",
"uber",
"venmo",
"vk_box",
"vk_circle",
"wunderlist",
"xda",
"xing_box",
"xing_circle",
"yelp",
// 6
"adobe_acrobat",
"adobe",
"amazon",
"amazon_alexa",
"android_auto",
"android_debug_bridge",
"bandcamp",
"battlenet",
"blogger",
"buffer",
"cash_usd_outline",
"cash_usd",
"concourse_ci",
"currency_usd_circle",
"currency_usd_circle_outline",
"douban",
"google_photos",
"home_currency_usd",
"microsoft_edge_legacy",
"microsoft_yammer",
"telegram",
"untappd",
"vk",
"xing",
"y_combinator",
// 7
"discord",
"google-home",
])
}