Skip to content

Commit

Permalink
Merge pull request #495 from lyskouski/BF-494
Browse files Browse the repository at this point in the history
[#494] [BF] Markdown alignments
  • Loading branch information
lyskouski authored Sep 25, 2024
2 parents 5ee414f + a807dc0 commit 4eabd5a
Show file tree
Hide file tree
Showing 30 changed files with 138 additions and 87 deletions.
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_يمكن الاطلاع على القائمة الكاملة للتحديثات من خلال عنصر التنقل "حول" الموجود على زر "تلميحات".

### 5.6.1
- معالجة اتجاه النص للترجمة من اليمين إلى اليسار في عمليات التوطين الموجهة من اليمين إلى اليسار

### 5.6.0
- تحسين الصفحات التمهيدية
- تقديم علامة تبويب ملخص الحسابات والميزانيات
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_az.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Yeniləmələrin tam siyahısına "İpucu" düyməsindəki "Haqqında" naviqasiya elementi vasitəsilə baxmaq olar._

### 5.6.1
- Sağdan sola yönümlü lokalizasiyalar üçün mətn oriyentasiyasının düzəldilməsi

### 5.6.0
- Giriş səhifələrinin təkmilləşdirilməsi
- Hesablar və Büdcələrin Xülasə nişanı ilə tanış olun
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_be.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Поўны спіс абнаўленьняў можна праглядзець у навігацыйным пункце «Аб дадатку» на кнопцы «Падказкі»._

### 5.6.1
- Выпраўленьне арыентацыі тэксту для лакалізацыі справа налева

### 5.6.0
- Паляпшэньне ўступных старонак
- Знаёмства з укладкай «Зводка ўліковых запісаў і бюджэтаў».
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_be_EU.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Poŭny spis abnaŭlieńniaŭ možna prahliadzieć u navihacyjnym punkcie «Ab Dadatku» na knopcy «Padkazki»._

### 5.6.1
- Vypraŭlieńnie aryjentacyi tekstu dlia lakalizacyi sprava nalieva

### 5.6.0
- Paliapšeńnie ŭstupnych staronak
- Znajomstva z ukladkaj «Zvodka ŭlikovych zapisaŭ i biudžetaŭ»
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Die vollständige Liste der Updates kann über den Navigationspunkt "Über" auf der Schaltfläche "Hinweise" eingesehen werden._

### 5.6.1
- Behebung der Textausrichtung für rechts-nach-links orientierte Lokalisierungen

### 5.6.0
- Verbesserung der Einführungsseiten
- Einführung der Registerkarte Konten- und Budgetzusammenfassung
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_The full list of updates can be viewed via the "About" navigation item on the "Hints" button._

### 5.6.1
- Remedying text orientation for right-to-left oriented localizations

### 5.6.0
- Enhancing introductory pages
- Introducing Accounts and Budgets Summary tab
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_La lista completa de actualizaciones puede consultarse en el menú "Acerca de" del botón "Sugerencias"._

### 5.6.1
- Corrección de la orientación del texto en localizaciones orientadas de derecha a izquierda

### 5.6.0
- Mejora de las páginas introductorias
- Introducción de la pestaña Resumen de cuentas y presupuestos
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_لیست کامل به روز رسانی ها را می توان از طریق آیتم پیمایش "درباره" در دکمه "نکات" مشاهده کرد.

### 5.6.1
- اصلاح جهت گیری متن برای محلی سازی های راست به چپ

### 5.6.0
- بهبود صفحات مقدماتی
- معرفی تب خلاصه حساب ها و بودجه ها
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_La liste complète des mises à jour peut être consultée via l'élément de navigation "À propos" du bouton "Conseils"._

### 5.6.1
- Correction de l'orientation du texte pour les localisations orientées de droite à gauche

### 5.6.0
- Amélioration des pages d'introduction
- Introduction de l'onglet Résumé des comptes et des budgets
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_hi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_अपडेट की पूरी सूची "संकेत" बटन पर "अबाउट" नेविगेशन आइटम के माध्यम से देखी जा सकती है।_

### 5.6.1
- दाएं से बाएं उन्मुख स्थानीयकरण के लिए पाठ अभिविन्यास का समाधान

### 5.6.0
- परिचयात्मक पृष्ठों को बेहतर बनाना
- खातों और बजट सारांश टैब का परिचय
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_it.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
_L'elenco completo degli aggiornamenti può essere consultato tramite la voce di navigazione “Informazioni” del
pulsante “Suggerimenti”._

### 5.6.1
- Correzione dell'orientamento del testo per le localizzazioni orientate da destra a sinistra

### 5.6.0
- Miglioramento delle pagine introduttive
- Introduzione della scheda Riepilogo conti e bilanci
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

更新の完全なリストは、「ヒント」ボタンの「バージョン情報」ナビゲーショ ンアイテムから見ることができます。

### 5.6.1
- 右から左へのローカライゼーションにおけるテキストの向きの修正

### 5.6.0
- 紹介ページの強化
- アカウントと予算のサマリータブの導入
Expand Down
5 changes: 4 additions & 1 deletion assets/l10n/upgrade_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Pełną listę aktualizacji można wyświetlić za pomocą elementu nawigacyjnego "O aplikacji" na przycisku "Wskazówki".

### 5.6.1
- Naprawiono orientację tekstu w lokalizacjach od prawej do lewej

### 5.6.0
- Ulepszenie stron wprowadzających
- Wprowadzenie zakładki podsumowania kont i budżetów
Expand Down Expand Up @@ -37,7 +40,7 @@ Pełną listę aktualizacji można wyświetlić za pomocą elementu nawigacyjneg
- Poprawa lokalizacji w języku perskim

### 5.3.0
- Dodanie perskiej lokalizacji.
- Dodanie perskiej lokalizacji

### 5.2.6
- Resolving Linux Flatpak storage
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_A lista completa de actualizações pode ser consultada através do item de navegação "Acerca" no botão "Sugestões".

### 5.6.1
- Correção da orientação do texto para localizações orientadas da direita para a esquerda

### 5.6.0
- Melhoria das páginas introdutórias
- Introdução do separador Resumo das contas e dos orçamentos
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_pt_BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_A lista completa de atualizações pode ser visualizada no item de navegação "Sobre" no botão "Dicas".

### 5.6.1
- Correção da orientação do texto para localizações orientadas da direita para a esquerda

### 5.6.0
- Aprimoramento das páginas introdutórias
- Introdução da guia Resumo de contas e orçamentos
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Güncellemelerin tam listesi “İpuçları” düğmesindeki “Hakkında” gezinti öğesi aracılığıyla görüntülenebilir._

### 5.6.1
- Sağdan sola yönlendirilmiş yerelleştirmeler için metin yönlendirmesi düzeltildi

### 5.6.0
- Giriş sayfalarının iyileştirilmesi
- Hesaplar ve Bütçeler Özet sekmesinin tanıtımı
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_uk.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Повний список оновлень можна переглянути за допомогою пункту навігації "Про додаток" на кнопці "Підказки"._

### 5.6.1
- Виправлення орієнтації тексту для локалізацій з орієнтацією справа наліво

### 5.6.0
- Покращення вступних сторінок
- Впровадження вкладки зведення рахунків та бюджетів
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_uz.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_Yangilanishlarning toʻliq roʻyxatini “Maslahat” tugmasidagi “Haqida” navigatsiya bandi orqali koʻrish mumkin._

### 5.6.1
- O'ngdan chapga yo'naltirilgan lokalizatsiya uchun matn yo'nalishini tuzatish

### 5.6.0
- Kirish sahifalarini yaxshilash
- Hisoblar va byudjetlar sarhisobi yorlig'i bilan tanishish
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

更新的完整列表可通过 "提示 "按钮上的 "关于 "导航项查看。

### 5.6.1
- 修正从右向左定位的文本方向

### 5.6.0
- 改进介绍页面
- 引入账户和预算摘要选项卡
Expand Down
3 changes: 3 additions & 0 deletions assets/l10n/upgrade_zh_TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

_完整的更新清單可透過「關於」導覽項目中的「提示」按鈕查看。_

### 5.6.1
- 修正從右至左定位的文字方向

### 5.6.0
- 強化介紹頁面
- 引入帳戶和預算摘要選項卡
Expand Down
45 changes: 45 additions & 0 deletions lib/design/wrapper/markdown_builder_wrapper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 The terCAD team. All rights reserved.
// Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.

import 'package:app_finance/_classes/herald/app_design.dart';
import 'package:app_finance/_mixins/launcher_mixin.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

class MarkdownBuilderWrapper extends StatelessWidget with LauncherMixin {
final String url;
final Widget Function(BuildContext, AsyncSnapshot<String>)? builder;
final Function(String, String?, String)? onTapLink;

const MarkdownBuilderWrapper({
super.key,
required this.url,
this.builder,
this.onTapLink,
});

_openURL(_, url, __) {
if (url != null && (url.contains('https://') || url.contains('mailto:'))) {
openURL(url);
}
}

@override
Widget build(BuildContext context) {
return FutureBuilder(
future: DefaultAssetBundle.of(context).loadString(url),
builder: builder ??
(BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasData) {
return Directionality(
textDirection: AppDesign.getAlignment<TextDirection>(),
child: Markdown(
data: (snapshot.data ?? '').replaceAll('../images', 'resource:assets/images'),
onTapLink: onTapLink ?? _openURL),
);
}
return Container();
},
);
}
}
15 changes: 4 additions & 11 deletions lib/pages/_interfaces/abstract_page_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ import 'package:app_finance/_classes/storage/app_data.dart';
import 'package:app_finance/_configs/screen_helper.dart';
import 'package:app_finance/_configs/theme_helper.dart';
import 'package:app_finance/_ext/build_context_ext.dart';
import 'package:app_finance/design/wrapper/markdown_builder_wrapper.dart';
import 'package:app_finance/pages/_interfaces/widgets/menu_widget.dart';
import 'package:app_finance/design/wrapper/input_controller_wrapper.dart';
import 'package:app_finance/design/wrapper/row_widget.dart';
import 'package:app_finance/design/wrapper/text_wrapper.dart';
import 'package:app_finance/design/button/toolbar_button_widget.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_grid_layout/flutter_grid_layout.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:provider/provider.dart';

abstract class AbstractPageState<T extends StatefulWidget> extends State<T> {
Expand Down Expand Up @@ -73,15 +72,9 @@ abstract class AbstractPageState<T extends StatefulWidget> extends State<T> {
),
),
Expanded(
child: FutureBuilder(
future: DefaultAssetBundle.of(context).loadString('./assets/l10n/${type}_$locale.md'),
builder: builder ??
(BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasData) {
return Markdown(data: snapshot.data!);
}
return Container();
},
child: MarkdownBuilderWrapper(
url: './assets/l10n/${type}_$locale.md',
builder: builder,
),
),
],
Expand Down
14 changes: 2 additions & 12 deletions lib/pages/about/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import 'package:app_finance/_classes/herald/app_locale.dart';
import 'package:app_finance/_configs/theme_helper.dart';
import 'package:app_finance/_ext/build_context_ext.dart';
import 'package:app_finance/_mixins/launcher_mixin.dart';
import 'package:app_finance/design/wrapper/markdown_builder_wrapper.dart';
import 'package:app_finance/pages/_interfaces/abstract_page_state.dart';
import 'package:app_finance/design/wrapper/row_widget.dart';
import 'package:app_finance/design/wrapper/tab_widget.dart';
import 'package:app_finance/design/wrapper/text_wrapper.dart';
import 'package:app_finance/pages/about/widgets/members_tab.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:package_info_plus/package_info_plus.dart';

class AboutPage extends StatefulWidget {
Expand Down Expand Up @@ -50,17 +50,7 @@ class AboutPageState extends AbstractPageState<AboutPage> with LauncherMixin {
@override
Widget buildButton(BuildContext context, BoxConstraints constraints) => ThemeHelper.emptyBox;

Widget buildMarkdown(String name) {
return FutureBuilder(
future: DefaultAssetBundle.of(context).loadString('./assets/l10n/$name.md'),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Markdown(data: snapshot.data ?? '');
}
return Container();
},
);
}
Widget buildMarkdown(String name) => MarkdownBuilderWrapper(url: './assets/l10n/$name.md');

@override
Widget buildContent(BuildContext context, BoxConstraints constraints) {
Expand Down
10 changes: 7 additions & 3 deletions lib/pages/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2023 The terCAD team. All rights reserved.
// Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file.

import 'package:app_finance/_classes/herald/app_design.dart';
import 'package:app_finance/_classes/storage/app_data.dart';
import 'package:app_finance/_classes/herald/app_locale.dart';
import 'package:app_finance/_classes/structure/currency/exchange.dart';
Expand All @@ -27,7 +28,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:intl/intl.dart';
import 'package:intl/intl.dart' as intl;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -68,7 +69,10 @@ class HomePageState extends AbstractPageState<HomePage> {
if (version.isNotEmpty) {
data = data.split('### $version')[0];
}
return Markdown(data: data);
return Directionality(
textDirection: AppDesign.getAlignment<TextDirection>(),
child: Markdown(data: data),
);
}
return Container();
},
Expand Down Expand Up @@ -186,7 +190,7 @@ class HomePageState extends AbstractPageState<HomePage> {

final billWidget = BillWidget(
margin: margin,
title: '${AppLocale.labels.billHeadline}, ${DateFormat.MMMM(AppLocale.code).format(DateTime.now())}',
title: '${AppLocale.labels.billHeadline}, ${intl.DateFormat.MMMM(AppLocale.code).format(DateTime.now())}',
state: state.get(AppDataType.bills),
limit: 7,
route: AppRoute.billRoute,
Expand Down
19 changes: 6 additions & 13 deletions lib/pages/start/widgets/about_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'package:app_finance/_mixins/launcher_mixin.dart';
import 'package:app_finance/design/form/list_selector_item.dart';
import 'package:app_finance/_configs/theme_helper.dart';
import 'package:app_finance/design/wrapper/input_wrapper.dart';
import 'package:app_finance/design/wrapper/markdown_builder_wrapper.dart';
import 'package:app_finance/l10n/index.dart';
import 'package:app_finance/pages/start/widgets/abstract_tab.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:provider/provider.dart';

class AboutTab extends AbstractTab {
Expand Down Expand Up @@ -60,18 +60,11 @@ class AboutTabState<T extends AboutTab> extends AbstractTabState<T> with Launche
onChange: (v) => saveLocale(v ?? AppLocale.code),
),
Expanded(
child: FutureBuilder(
future: DefaultAssetBundle.of(context).loadString('./assets/l10n/about_${locale.value!}.md'),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
if (snapshot.hasData) {
return Markdown(
data: snapshot.data!.replaceAll('../images', 'resource:assets/images'),
onTapLink: (_, link, __) => link != null && link.contains('youtu.be')
? openURL(link)
: saveLocale(link?.replaceFirst('./about_', '').replaceFirst('.md', '') ?? AppLocale.code));
}
return Container();
},
child: MarkdownBuilderWrapper(
url: './assets/l10n/about_${locale.value!}.md',
onTapLink: (_, link, __) => link != null && link.contains('https://')
? openURL(link)
: saveLocale(link?.replaceFirst('./about_', '').replaceFirst('.md', '') ?? AppLocale.code),
),
),
],
Expand Down
Loading

0 comments on commit 4eabd5a

Please sign in to comment.