@ -37,6 +37,9 @@ struct CreateQRCodeView: View {
@ State private var contactTitle = " "
@ State private var contactTitle = " "
@ State private var contactAddress = " "
@ State private var contactAddress = " "
@ State private var contactWebsite = " "
@ State private var contactWebsite = " "
@ State private var contactNickname = " "
@ State private var contactBirthday = Date ( )
@ State private var contactNote = " "
@ FocusState private var focusedContactField : ContactInputView . ContactField ?
@ FocusState private var focusedContactField : ContactInputView . ContactField ?
// 位 置 相 关 字 段
// 位 置 相 关 字 段
@ -173,7 +176,10 @@ struct CreateQRCodeView: View {
company : $ contactCompany ,
company : $ contactCompany ,
title : $ contactTitle ,
title : $ contactTitle ,
address : $ contactAddress ,
address : $ contactAddress ,
website : $ contactWebsite
website : $ contactWebsite ,
nickname : $ contactNickname ,
birthday : $ contactBirthday ,
note : $ contactNote
)
)
return InputComponentFactory . createInputComponent (
return InputComponentFactory . createInputComponent (
for : selectedQRCodeType ,
for : selectedQRCodeType ,
@ -433,24 +439,55 @@ struct CreateQRCodeView: View {
return vcard
return vcard
case . mecard :
case . mecard :
var mecard = " MECARD: "
var mecard = " MECARD: "
// 姓 名 字 段
if ! contactFirstName . isEmpty || ! contactLastName . isEmpty {
if ! contactFirstName . isEmpty || ! contactLastName . isEmpty {
mecard += " N: \( contactLastName ) , \( contactFirstName ) ; "
let lastName = contactLastName . isEmpty ? " " : contactLastName
let firstName = contactFirstName . isEmpty ? " " : contactFirstName
mecard += " N: \( lastName ) , \( firstName ) ; "
}
// 昵 称 字 段
if ! contactNickname . isEmpty {
mecard += " NICKNAME: \( contactNickname ) ; "
}
}
// 电 话 字 段
if ! contactPhone . isEmpty {
if ! contactPhone . isEmpty {
mecard += " TEL: \( contactPhone ) ; "
mecard += " TEL: \( contactPhone ) ; "
}
}
// 邮 箱 字 段
if ! contactEmail . isEmpty {
if ! contactEmail . isEmpty {
mecard += " EMAIL: \( contactEmail ) ; "
mecard += " EMAIL: \( contactEmail ) ; "
}
}
// 公 司 字 段
if ! contactCompany . isEmpty {
if ! contactCompany . isEmpty {
mecard += " ORG: \( contactCompany ) ; "
mecard += " ORG: \( contactCompany ) ; "
}
}
// 地 址 字 段
if ! contactAddress . isEmpty {
if ! contactAddress . isEmpty {
mecard += " ADR: \( contactAddress ) ; "
mecard += " ADR: \( contactAddress ) ; "
}
}
// 网 站 字 段
if ! contactWebsite . isEmpty {
if ! contactWebsite . isEmpty {
mecard += " URL: \( contactWebsite ) ; "
mecard += " URL: \( contactWebsite ) ; "
}
}
// 生 日 字 段
let dateFormatter = DateFormatter ( )
dateFormatter . dateFormat = " yyyyMMdd "
let birthdayString = dateFormatter . string ( from : contactBirthday )
mecard += " BDAY: \( birthdayString ) ; "
// 备 注 字 段
if ! contactNote . isEmpty {
mecard += " NOTE: \( contactNote ) ; "
}
mecard += " ; "
mecard += " ; "
return mecard
return mecard
case . location :
case . location :
@ -518,7 +555,35 @@ struct CreateQRCodeView: View {
case . wifi :
case . wifi :
historyItem . content = " WiFi: \( wifiSSID ) ( \( wifiEncryptionType . displayName ) ) "
historyItem . content = " WiFi: \( wifiSSID ) ( \( wifiEncryptionType . displayName ) ) "
case . vcard , . mecard :
case . vcard , . mecard :
historyItem . content = " 联系人: \( contactFirstName ) \( contactLastName ) "
var contactContent = " 联系人: "
if ! contactFirstName . isEmpty || ! contactLastName . isEmpty {
contactContent += " \( contactFirstName ) \( contactLastName ) "
}
if ! contactNickname . isEmpty {
contactContent += " ( \( contactNickname ) ) "
}
if ! contactPhone . isEmpty {
contactContent += " \n 电话: \( contactPhone ) "
}
if ! contactEmail . isEmpty {
contactContent += " \n 邮箱: \( contactEmail ) "
}
if ! contactCompany . isEmpty {
contactContent += " \n 公司: \( contactCompany ) "
}
if ! contactTitle . isEmpty {
contactContent += " \n 职位: \( contactTitle ) "
}
if ! contactAddress . isEmpty {
contactContent += " \n 地址: \( contactAddress ) "
}
if ! contactWebsite . isEmpty {
contactContent += " \n 网站: \( contactWebsite ) "
}
if ! contactNote . isEmpty {
contactContent += " \n 备注: \( contactNote ) "
}
historyItem . content = contactContent
case . location :
case . location :
historyItem . content = " 位置: \( locationLatitude ) , \( locationLongitude ) "
historyItem . content = " 位置: \( locationLatitude ) , \( locationLongitude ) "
case . calendar :
case . calendar :