diff --git a/README.md b/README.md index 418f2f0dd03e5635a4fd4cbf3277d99bae41eb35..46ab9dfb8f7f19bca1230d872b76e41cb7ff909b 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ class AppConfig { - Cliquez sur "Créer des identifiants" et sélectionnez "Clé API". - Copiez la clé API générée. +#### Autorisation de lecture et d'écriture : + +- Autorisez la lecture et l'écriture de votre feuille de calcul sur Google Sheets. + #### Récupération du sheet name : - Ouvrez votre document Google Sheets. @@ -37,3 +41,13 @@ flutter build linux ```shell flutter build apk ``` + +### Application + +#### Affichage des données + +![Affichage des données](assets/images/affichage.png) + +#### Génération de PDF + +![Génération de PDF](assets/images/pdf.png) diff --git a/assets/images/affichage.png b/assets/images/affichage.png new file mode 100644 index 0000000000000000000000000000000000000000..cfc9131e3c8f6fb2371ddc957849a29ab3558be1 Binary files /dev/null and b/assets/images/affichage.png differ diff --git a/assets/images/pdf.png b/assets/images/pdf.png new file mode 100644 index 0000000000000000000000000000000000000000..a5d7501707a1f3002c84f9716e6764ec7fc76dfd Binary files /dev/null and b/assets/images/pdf.png differ diff --git a/lib/main.dart b/lib/main.dart index b77089e381075aa3f1159685ea237cd0d9442d70..cdc9a23ead98c0020320487a49b9573e1f7070da 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -174,17 +174,20 @@ class _DataPageState extends State { Future generatePdf(List> sheetData) async { final pdf = pw.Document(); - final List rows = []; + final List rows = []; for (final row in sheetData) { - final String rowData = row.map((cell) => '$cell').join(' ; '); - rows.add(pw.Text(rowData)); + final List rowWidgets = row.map((cell) => pw.Text('$cell')).toList(); + rows.add(pw.TableRow(children: rowWidgets)); } pdf.addPage(pw.Page( build: (pw.Context context) { - return pw.Column( - crossAxisAlignment: pw.CrossAxisAlignment.start, + return pw.Table( + columnWidths: { + for (int i = 0; i < sheetData[0].length; i++) + i: pw.FixedColumnWidth(100.0), + }, children: rows, ); }, @@ -217,7 +220,40 @@ class _DataPageState extends State { TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold), ), const SizedBox(height: 10.0), - for (List row in _sheetData) Text(row.join(' ; ')), + Table( + border: TableBorder.all(), + columnWidths: { + for (int i = 0; i < _sheetData[0].length; i++) + i: FixedColumnWidth(100.0), + }, + children: _sheetData.map((row) { + if (row.length < _sheetData[0].length) { + final filledRow = List.from(row) + ..addAll(List.generate( + _sheetData[0].length - row.length, (_) => '')); + + return TableRow( + children: filledRow.map((cell) => Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + '$cell', + style: TextStyle(fontWeight: FontWeight.bold), + ), + )).toList(), + ); + } else { + return TableRow( + children: row.map((cell) => Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + '$cell', + style: TextStyle(fontWeight: FontWeight.bold), + ), + )).toList(), + ); + } + }).toList(), + ), const SizedBox(height: 20.0), Row( children: [