Skip to content

Commit

Permalink
vCard 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianAldair committed May 18, 2023
1 parent 2fc2f90 commit 7921f62
Show file tree
Hide file tree
Showing 6 changed files with 961 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.0.5 - VCard 1.0

* vCard 1.0
- Convert plain text to dart object
- Convert dart object to plain text
- copyWith function

## 0.0.4 - MeCard fixes

* Specification that the MeCard being represented is version 2.1
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ Ideal for working in applications using QR readers.
| Format | Text to Object | Object to Text |
|:----------:|:--------------:|:--------------:|
| MeCard 2.1 |||
| vCard 1.0 | | |
| vCard 1.0 | | |
| vCard 2.1 |||
| vCard 3.0 |||
| vCard 4.0 |||

For vCards, the following fields are missing to be implemented:
- CLIENTPIDMAP
- KEY
- LABEL
- LOGO
- MEMBER
- NAME
- PHOTP
- PRODID
- RELATED
- SOUND
- TZ
- UID

## Getting started

Just import this library in the pubspec.yaml.
Expand All @@ -30,7 +44,10 @@ All done.
## Usage
```dart
final MeCard card = MeCard.fromPlainText(sampleText);
final String plainText = card.toPlainText();
final MeCard card1 = MeCard.fromPlainText(sampleText1);
final String plainText1 = card1.toPlainText();

final VCard1 card2 = MeCard.fromPlainText(sampleText2);
final String plainText2 = card2.toPlainText();
```

30 changes: 30 additions & 0 deletions example/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import 'package:contact_card/cards/mecard.dart';
import 'package:contact_card/cards/vcard.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

const mecardText =
'MECARD:N:Doe,John;ORG:ABC Company;TEL:+123456789;TEL:+987654321;EMAIL:[email protected];ADR:123 Main St, Anytown, CA 12345;NOTE:This is a note;BDAY:1970-01-01;URL:http://www.abccompany.com;TITLE:Marketing Director;NICKNAME:Johnny;X-SOCIALPROFILE;type=twitter:http://twitter.com/johndoe;X-SOCIALPROFILE;type=linkedin:http://www.linkedin.com/in/johndoe;;';

const vcard1Text = '''
BEGIN:VCARD
VERSION:1.0
N:Gonzalez;Juan;;;
FN:Juan Gonzalez
TEL:555-1234
TEL;HOME:555-5678
ADR;WORK:;;123 Main St.;Anytown;CA;12345;USA
ADR;HOME:;;456 Oak St.;Othertown;CA;67890;USA
EMAIL:[email protected]
EMAIL:[email protected]
ORG:Acme Inc.;Sales Department
TITLE:Sales Representative
ROLE:Sales
URL:http://www.johndoe.com
PHOTO;JPEG:http://www.example.com/photo.jpg
LOGO;GIF:http://www.example.com/logo.gif
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Acme Inc.=0D=0ASales Department=0D=0A123 Main St.=0D=0AAnytown, CA 12345=0D=0AUSA
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:456 Oak St.=0D=0AOthertown, CA 67890=0D=0AUSA
END:VCARD''';

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

Expand All @@ -32,6 +54,14 @@ class MyApp extends StatelessWidget {
debugPrint(card.toPlainText());
},
),
ElevatedButton(
child: const Text('vCard 1.0'),
onPressed: () {
final card = VCard1.fromPlainText(vcard1Text);
debugPrint(card.toString());
debugPrint(card.toPlainText());
},
),
],
),
),
Expand Down
Loading

0 comments on commit 7921f62

Please sign in to comment.