Flutter update (#1048)

* Update Flutter
Update packages

* Fix localization issues
Fix UI issues
Update old packages
Update workflow
Update how to build guide

* Additional UI fixes for merged conflicts
This commit is contained in:
Omar Hatem 2023-08-18 18:37:17 +03:00 committed by GitHub
parent 09c942564e
commit 9ddab2b472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 311 additions and 282 deletions

View file

@ -18,7 +18,7 @@ jobs:
- name: Flutter action
uses: subosito/flutter-action@v1
with:
flutter-version: '3.3.x'
flutter-version: '3.10.x'
channel: stable
- name: Install package dependencies

View file

@ -28,7 +28,7 @@ jobs:
- name: Flutter action
uses: subosito/flutter-action@v1
with:
flutter-version: '3.7.x'
flutter-version: '3.10.x'
channel: stable
- name: Install package dependencies

View file

@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

View file

@ -13,16 +13,16 @@ dependencies:
flutter:
sdk: flutter
path_provider: ^2.0.11
http: ^0.13.4
http: ^1.1.0
mobx: ^2.0.7+4
flutter_mobx: ^2.0.6+1
intl: ^0.17.0
intl: ^0.18.0
cw_core:
path: ../cw_core
bitcoin_flutter:
git:
url: https://github.com/cake-tech/bitcoin_flutter.git
ref: cake-update-v2
ref: cake-update-v3
rxdart: ^0.27.5
unorm_dart: ^0.2.0
cryptography: ^2.0.5

View file

@ -12,12 +12,12 @@ environment:
dependencies:
flutter:
sdk: flutter
http: ^0.13.4
http: ^1.1.0
file: ^6.1.4
path_provider: ^2.0.11
mobx: ^2.0.7+4
flutter_mobx: ^2.0.6+1
intl: ^0.17.0
intl: ^0.18.0
encrypt: ^5.0.1
dev_dependencies:

View file

@ -9,7 +9,7 @@ import 'package:cw_ethereum/pending_ethereum_transaction.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
import 'package:web3dart/contracts/erc20.dart';
import 'package:erc20/erc20.dart';
import 'package:cw_core/node.dart';
import 'package:cw_ethereum/ethereum_transaction_priority.dart';
import 'package:cw_ethereum/.secrets.g.dart' as secrets;
@ -72,7 +72,7 @@ class EthereumClient {
to: EthereumAddress.fromHex(toAddress),
maxGas: gas,
gasPrice: price,
maxPriorityFeePerGas: EtherAmount.fromUnitAndValue(EtherUnit.gwei, priority.tip),
maxPriorityFeePerGas: EtherAmount.fromInt(EtherUnit.gwei, priority.tip),
value: _isEthereum ? EtherAmount.inWei(BigInt.parse(amount)) : EtherAmount.zero(),
);
@ -83,7 +83,7 @@ class EthereumClient {
if (_isEthereum) {
_sendTransaction = () async => await sendTransaction(signedTransaction);
} else {
final erc20 = Erc20(
final erc20 = ERC20(
client: _client!,
address: EthereumAddress.fromHex(contractAddress!),
);
@ -153,7 +153,7 @@ I/flutter ( 4474): Gas Used: 53000
Future<ERC20Balance> fetchERC20Balances(
EthereumAddress userAddress, String contractAddress) async {
final erc20 = Erc20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
final erc20 = ERC20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
final balance = await erc20.balanceOf(userAddress);
int exponent = (await erc20.decimals()).toInt();
@ -163,7 +163,7 @@ I/flutter ( 4474): Gas Used: 53000
Future<Erc20Token?> getErc20Token(String contractAddress) async {
try {
final erc20 = Erc20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
final erc20 = ERC20(address: EthereumAddress.fromHex(contractAddress), client: _client!);
final name = await erc20.name();
final symbol = await erc20.symbol();
final decimal = await erc20.decimals();

View file

@ -12,13 +12,14 @@ environment:
dependencies:
flutter:
sdk: flutter
web3dart: 2.3.5
web3dart: ^2.7.1
erc20: ^1.0.1
mobx: ^2.0.7+4
bip39: ^1.0.6
bip32: ^2.0.0
ed25519_hd_key: ^2.2.0
hex: ^0.2.0
http: ^0.13.4
http: ^1.1.0
shared_preferences: ^2.0.15
cw_core:
path: ../cw_core

View file

@ -13,11 +13,11 @@ dependencies:
flutter:
sdk: flutter
ffi: ^2.0.1
http: ^0.13.4
http: ^1.1.0
path_provider: ^2.0.11
mobx: ^2.0.7+4
flutter_mobx: ^2.0.6+1
intl: ^0.17.0
intl: ^0.18.0
cw_core:
path: ../cw_core

View file

@ -13,11 +13,11 @@ dependencies:
flutter:
sdk: flutter
ffi: ^2.0.1
http: ^0.13.4
http: ^1.1.0
path_provider: ^2.0.11
mobx: ^2.0.7+4
flutter_mobx: ^2.0.6+1
intl: ^0.17.0
intl: ^0.18.0
encrypt: ^5.0.1
cw_core:
path: ../cw_core

View file

@ -5,7 +5,7 @@ author: Cake Walelt
homepage: https://cakewallet.com
environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
dependencies:

View file

@ -5,10 +5,10 @@
The following are the system requirements to build CakeWallet for your Android device.
```
Ubuntu >= 16.04
Ubuntu >= 20.04
Android SDK 29 or higher (better to have the latest one 33)
Android NDK 17c
Flutter 3.7.x
Flutter 3.10.x or earlier
```
## Building CakeWallet on Android
@ -66,7 +66,7 @@ Verify that the Android toolchain, Flutter, and Android Studio have been correct
The output of this command will appear like this, indicating successful installations. If there are problems with your installation, they **must** be corrected before proceeding.
```
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.x, on Linux, locale en_US.UTF-8)
[✓] Flutter (Channel stable, 3.10.x, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29 or higher)
[✓] Android Studio (version 4.0 or higher)
```

View file

@ -1,4 +1,3 @@
import 'package:uuid/uuid.dart';
import 'package:cw_core/key.dart';
String generateWalletPassword() {

View file

@ -736,6 +736,21 @@ class HaMaterialLocalizations extends GlobalMaterialLocalizations {
@override
String get keyboardKeySpace => 'Space';
@override
String get bottomSheetLabel => "Bottom Sheet";
@override
String get currentDateLabel => "Current Date";
@override
String get keyboardKeyShift => "Shift";
@override
String get scrimLabel => "Scrim";
@override
String get scrimOnTapHintRaw => "Scrip on Tap";
}
/// Cupertino Support
@ -937,4 +952,7 @@ class HaCupertinoLocalizations extends GlobalCupertinoLocalizations {
static const LocalizationsDelegate<CupertinoLocalizations> delegate =
_HaCupertinoLocalizationsDelegate();
@override
String get noSpellCheckReplacementsLabel => "";
}

View file

@ -736,6 +736,21 @@ String get keyboardKeyMetaWindows => 'Windows';
@override
String get keyboardKeySpace => 'Space';
@override
String get bottomSheetLabel => "Bottom Sheet";
@override
String get currentDateLabel => "Current Date";
@override
String get keyboardKeyShift => "Shift";
@override
String get scrimLabel => "Scrim";
@override
String get scrimOnTapHintRaw => "Scrip on Tap";
}
/// Cupertino Support
@ -937,4 +952,7 @@ String get todayLabel => 'Oyọ';
static const LocalizationsDelegate<CupertinoLocalizations> delegate =
_YoCupertinoLocalizationsDelegate();
@override
String get noSpellCheckReplacementsLabel => "";
}

View file

@ -13,7 +13,6 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/yat_emoji_id.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart';
@ -109,7 +108,7 @@ class _DashboardPageView extends BasePage {
Widget trailing(BuildContext context) {
final menuButton = Image.asset(
'assets/images/menu.png',
color: Theme.of(context).accentTextTheme.displayMedium!.backgroundColor,
color: Theme.of(context).extension<DashboardPageTheme>()!.pageTitleTextColor,
);
return Container(
@ -128,6 +127,7 @@ class _DashboardPageView extends BasePage {
final DashboardViewModel dashboardViewModel;
final WalletAddressListViewModel addressListViewModel;
int get initialPage => dashboardViewModel.shouldShowMarketPlaceInDashboard ? 1 : 0;
ObservableList<Widget> pages = ObservableList<Widget>();
bool _isEffectsInstalled = false;

View file

@ -1,5 +1,4 @@
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/entities/receive_page_option.dart';
@ -64,14 +63,6 @@ class AddressPage extends BasePage {
@override
Widget? leading(BuildContext context) {
final _backButton = Icon(
Icons.arrow_back_ios,
color: Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
size: 16,
);
final _closeButton =
currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage;
bool isMobileView = ResponsiveLayoutUtil.instance.isMobile;
return MergeSemantics(
@ -119,11 +110,7 @@ class AddressPage extends BasePage {
context: context,
);
},
icon: Icon(
Icons.share,
size: 20,
color: Theme.of(context).accentTextTheme.displayMedium!.backgroundColor!,
),
icon: Icon(Icons.share, size: 20, color: pageIconColor(context)),
),
);
}
@ -160,10 +147,10 @@ class AddressPage extends BasePage {
return KeyboardActions(
autoScroll: false,
disableScroll: true,
tapOutsideToDismiss: true,
tapOutsideBehavior: TapOutsideBehavior.translucentDismiss,
config: KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor: Theme.of(context).accentTextTheme.bodyLarge!.backgroundColor!,
keyboardBarColor: Theme.of(context).extension<KeyboardTheme>()!.keyboardBarColor,
nextFocus: false,
actions: [
KeyboardActionsItem(

View file

@ -5,7 +5,6 @@ import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/desktop_exchange_cards_section.dart';
import 'package:cake_wallet/src/screens/exchange/widgets/mobile_exchange_cards_section.dart';
import 'package:cake_wallet/src/widgets/add_template_button.dart';
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/utils/debounce.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
@ -250,7 +249,7 @@ class ExchangePage extends BasePage {
}
}
},
color: Theme.of(context).accentTextTheme.bodyLarge!.color!,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
isDisabled: exchangeViewModel.selectedProviders.isEmpty,
isLoading: exchangeViewModel.tradeState is TradeIsCreating)),

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
@ -24,7 +25,7 @@ class RestoreButton extends StatelessWidget {
alignment: Alignment.topLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12)),
color: Theme.of(context).accentTextTheme.bodySmall!.color!,
color: Theme.of(context).cardColor,
),
child: Row(
mainAxisSize: MainAxisSize.max,
@ -45,10 +46,8 @@ class RestoreButton extends StatelessWidget {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme
.titleLarge!
.color!),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
),
Padding(
padding: EdgeInsets.only(top: 5),
@ -58,9 +57,9 @@ class RestoreButton extends StatelessWidget {
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context)
.primaryTextTheme
.labelSmall!
.color!),
.extension<TransactionTradeTheme>()!
.detailsTitlesColor,
),
),
)
],

View file

@ -6,8 +6,6 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
class PreSeedPage extends BasePage {
@ -62,7 +60,7 @@ class PreSeedPage extends BasePage {
onPressed: () =>
Navigator.of(context).popAndPushNamed(Routes.seed, arguments: true),
text: S.of(context).pre_seed_button_text,
color: Theme.of(context).accentTextTheme.bodyLarge!.color!,
color: Theme.of(context).primaryColor,
textColor: Colors.white)
],
),

View file

@ -208,14 +208,8 @@ class SendPage extends BasePage {
radius: 6.0,
dotWidth: 6.0,
dotHeight: 6.0,
dotColor: Theme.of(context)
.primaryTextTheme!
.displaySmall!
.backgroundColor!,
activeDotColor: Theme.of(context)
.primaryTextTheme!
.displayMedium!
.backgroundColor!),
dotColor: Theme.of(context).extension<SendPageTheme>()!.indicatorDotColor,
activeDotColor: Theme.of(context).extension<SendPageTheme>()!.templateBackgroundColor),
)
: Offstage();
},
@ -340,10 +334,7 @@ class SendPage extends BasePage {
text:
'Change your asset (${sendViewModel.selectedCryptoCurrency})',
color: Colors.transparent,
textColor: Theme.of(context)
.accentTextTheme!
.displaySmall!
.decorationColor!,
textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
))),
if (sendViewModel.sendTemplateViewModel.hasMultiRecipient)
Padding(
@ -358,15 +349,9 @@ class SendPage extends BasePage {
},
text: S.of(context).add_receiver,
color: Colors.transparent,
textColor: Theme.of(context)
.accentTextTheme!
.displaySmall!
.decorationColor!,
textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
isDottedBorder: true,
borderColor: Theme.of(context)
.primaryTextTheme!
.displaySmall!
.decorationColor!,
borderColor: Theme.of(context).extension<SendPageTheme>()!.templateDottedBorderColor,
)),
Observer(
builder: (_) {
@ -387,7 +372,7 @@ class SendPage extends BasePage {
item.cryptoAmount.isEmpty)
.toList();
if (notValidItems.isNotEmpty ?? false) {
if (notValidItems.isNotEmpty) {
showErrorValidationAlert(context);
return;
}

View file

@ -167,8 +167,8 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
AddressTextFieldOption.qrCode,
AddressTextFieldOption.addressBook
],
buttonColor: Theme.of(context).primaryTextTheme.headlineMedium!.color!,
borderColor: Theme.of(context).primaryTextTheme.headlineSmall!.color!,
buttonColor: Theme.of(context).extension<SendPageTheme>()!.textFieldButtonColor,
borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
textStyle: TextStyle(
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
hintStyle: TextStyle(
@ -403,14 +403,11 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
),
),
hintText: '0.00',
borderColor: Theme.of(context).primaryTextTheme.headlineSmall!.color!,
borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
textStyle: TextStyle(
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
placeholderTextStyle: TextStyle(
color: Theme.of(context)
.primaryTextTheme
.headlineSmall!
.decorationColor!,
color: Theme.of(context).extension<SendPageTheme>()!.textFieldHintColor,
fontWeight: FontWeight.w500,
fontSize: 14),
),
@ -421,7 +418,7 @@ class SendCardState extends State<SendCard> with AutomaticKeepAliveClientMixin<S
controller: noteController,
keyboardType: TextInputType.multiline,
maxLines: null,
borderColor: Theme.of(context).primaryTextTheme.headlineSmall!.color!,
borderColor: Theme.of(context).extension<SendPageTheme>()!.textFieldBorderColor,
textStyle: TextStyle(
fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white),
hintText: S.of(context).note_optional,

View file

@ -59,7 +59,7 @@ class SettingsChoicesCell extends StatelessWidget {
style: TextStyle(
color: isSelected
? Colors.white
: Theme.of(context).primaryTextTheme.bodySmall!.color!,
: Theme.of(context).extension<CakeTextTheme>()!.secondaryTextColor,
fontWeight: isSelected ? FontWeight.w700 : FontWeight.normal,
),
),

View file

@ -1,10 +1,8 @@
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/themes/extensions/receive_page_theme.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
import 'package:another_flushbar/flushbar.dart';
import 'package:flutter/material.dart';
@ -94,8 +92,7 @@ class WalletListBodyState extends State<WalletListBody> {
width: 4,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(4),
bottomRight: Radius.circular(4)),
topRight: Radius.circular(4), bottomRight: Radius.circular(4)),
color: currentColor),
),
Expanded(
@ -107,9 +104,7 @@ class WalletListBodyState extends State<WalletListBody> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
wallet.isEnabled
? _imageFor(type: wallet.type)
: nonWalletTypeIcon,
wallet.isEnabled ? _imageFor(type: wallet.type) : nonWalletTypeIcon,
SizedBox(width: 10),
Flexible(
child: Text(
@ -119,20 +114,24 @@ class WalletListBodyState extends State<WalletListBody> {
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.extension<CakeTextTheme>()!
.titleColor),
))
]),
color:
Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
),
),
],
),
));
),
),
],
),
),
);
return wallet.isCurrent
? row
: Row(children: [
: Row(
children: [
Expanded(child: row),
GestureDetector(
onTap: () => Navigator.of(context).pushNamed(Routes.walletEdit,
@ -148,24 +147,27 @@ class WalletListBodyState extends State<WalletListBody> {
shape: BoxShape.circle,
color: Theme.of(context)
.extension<ReceivePageTheme>()!
.iconsBackgroundColor),
.iconsBackgroundColor,
),
child: Icon(
Icons.edit,
size: 14,
color: Theme.of(context)
.extension<ReceivePageTheme>()!
.iconsColor,
color:
Theme.of(context).extension<ReceivePageTheme>()!.iconsColor,
),
),
),
),
)
]);
}),
),
],
);
},
),
),
),
bottomSectionPadding: EdgeInsets.only(bottom: 24, right: 24, left: 24),
bottomSection: Column(children: <Widget>[
bottomSection: Column(
children: <Widget>[
PrimaryImageButton(
onPressed: () {
//TODO(David): Find a way to optimize this
@ -199,7 +201,7 @@ class WalletListBodyState extends State<WalletListBody> {
},
image: newWalletImage,
text: S.of(context).wallet_list_create_new_wallet,
color: Theme.of(context).accentTextTheme.bodyLarge!.color!,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
),
SizedBox(height: 10.0),
@ -219,9 +221,12 @@ class WalletListBodyState extends State<WalletListBody> {
},
image: restoreWalletImage,
text: S.of(context).wallet_list_restore_wallet,
color: Theme.of(context).accentTextTheme.bodySmall!.color!,
textColor: Theme.of(context).primaryTextTheme.titleLarge!.color!)
])),
color: Theme.of(context).cardColor,
textColor: Theme.of(context).extension<CakeTextTheme>()!.buttonTextColor,
)
],
),
),
);
}

View file

@ -72,7 +72,10 @@ class SectionHeaderListRow extends StatelessWidget {
Widget build(BuildContext context) => Column(children: [
StandardListSeparator(padding: EdgeInsets.only(left: 24)),
Container(
width: double.infinity, height: 40, color: Theme.of(context).colorScheme.background),
width: double.infinity,
height: 40,
color: Theme.of(context).colorScheme.background,
),
//StandardListSeparator(padding: EdgeInsets.only(left: 24))
]);
}
@ -90,7 +93,10 @@ class StandardListSeparator extends StatelessWidget {
padding: padding,
color: Theme.of(context).colorScheme.background,
child: Container(
height: height, color: Theme.of(context).primaryTextTheme.titleLarge?.backgroundColor));
height: height,
color: Theme.of(context).extension<CakeTextTheme>()!.textfieldUnderlineColor,
),
);
}
}

View file

@ -3,14 +3,13 @@ dependencies:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.17.0
intl: ^0.18.0
url_launcher: ^6.1.4
qr_flutter:
git:
url: https://github.com/cake-tech/qr.flutter.git
ref: cake-4.0.2
version: 4.0.2
uuid: 3.0.6
shared_preferences: ^2.0.15
flutter_secure_storage:
git:
@ -23,7 +22,7 @@ dependencies:
yaml: ^3.1.1
#barcode_scan: any
barcode_scan2: ^4.2.1
http: ^0.13.4
http: ^1.1.0
path_provider: ^2.0.11
mobx: ^2.1.4
flutter_mobx: ^2.0.6+5
@ -53,7 +52,7 @@ dependencies:
encrypt: ^5.0.1
crypto: ^3.0.2
# password: ^1.0.0
basic_utils: ^4.3.0
basic_utils: ^5.6.1
get_it: ^7.2.0
# connectivity: ^3.0.3
connectivity_plus: ^2.3.5
@ -86,13 +85,13 @@ dependencies:
bitcoin_flutter:
git:
url: https://github.com/cake-tech/bitcoin_flutter.git
ref: cake-update-v2
ref: cake-update-v3
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.3.3
logging: 1.1.1
logging: ^1.2.0
mobx_codegen: ^2.1.1
build_resolvers: ^2.0.9
hive_generator: ^1.1.3
@ -100,7 +99,7 @@ dev_dependencies:
# check flutter_launcher_icons for usage
pedantic: ^1.8.0
# replace https://github.com/dart-lang/lints#migrating-from-packagepedantic
translator: ^0.1.7
# translator: ^0.1.7
flutter_icons:
image_path: "assets/images/app_logo.png"

View file

@ -1,66 +1,66 @@
import 'dart:convert';
import 'dart:io';
import 'package:translator/translator.dart';
const defaultLang = "en";
const langs = [
"ar", "bg", "cs", "de", "en", "es", "fr", "ha", "hi", "hr", "id", "it",
"ja", "ko", "my", "nl", "pl", "pt", "ru", "th", "tr", "uk", "ur", "yo",
"zh-cn" // zh, but Google Translate uses zh-cn for Chinese (Simplified)
];
final translator = GoogleTranslator();
void main(List<String> args) async {
if (args.length != 2) {
throw Exception(
'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!"`');
}
final name = args.first;
final text = args.last;
print('Appending "$name": "$text"');
for (var lang in langs) {
final fileName = getFileName(lang);
final translation = await getTranslation(text, lang);
appendArbFile(fileName, name, translation);
}
}
void appendArbFile(String fileName, String name, String text) {
final file = File(fileName);
final inputContent = file.readAsStringSync();
final arbObj = json.decode(inputContent) as Map<String, dynamic>;
if (arbObj.containsKey(name)) {
print("String $name already exists in $fileName!");
return;
}
arbObj.addAll({name: text});
final outputContent = json
.encode(arbObj)
.replaceAll('","', '",\n "')
.replaceAll('{"', '{\n "')
.replaceAll('"}', '"\n}')
.replaceAll('":"', '": "');
file.writeAsStringSync(outputContent);
}
Future<String> getTranslation(String text, String lang) async {
if (lang == defaultLang) return text;
return (await translator.translate(text, from: defaultLang, to: lang)).text;
}
String getFileName(String lang) {
final shortLang = lang
.split("-")
.first;
return "./res/values/strings_$shortLang.arb";
}
// import 'dart:convert';
// import 'dart:io';
//
// import 'package:translator/translator.dart';
//
// const defaultLang = "en";
// const langs = [
// "ar", "bg", "cs", "de", "en", "es", "fr", "ha", "hi", "hr", "id", "it",
// "ja", "ko", "my", "nl", "pl", "pt", "ru", "th", "tr", "uk", "ur", "yo",
// "zh-cn" // zh, but Google Translate uses zh-cn for Chinese (Simplified)
// ];
// final translator = GoogleTranslator();
//
// void main(List<String> args) async {
// if (args.length != 2) {
// throw Exception(
// 'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!"`');
// }
//
// final name = args.first;
// final text = args.last;
//
// print('Appending "$name": "$text"');
//
// for (var lang in langs) {
// final fileName = getFileName(lang);
// final translation = await getTranslation(text, lang);
//
// appendArbFile(fileName, name, translation);
// }
// }
//
// void appendArbFile(String fileName, String name, String text) {
// final file = File(fileName);
// final inputContent = file.readAsStringSync();
// final arbObj = json.decode(inputContent) as Map<String, dynamic>;
//
// if (arbObj.containsKey(name)) {
// print("String $name already exists in $fileName!");
// return;
// }
//
// arbObj.addAll({name: text});
//
// final outputContent = json
// .encode(arbObj)
// .replaceAll('","', '",\n "')
// .replaceAll('{"', '{\n "')
// .replaceAll('"}', '"\n}')
// .replaceAll('":"', '": "');
//
// file.writeAsStringSync(outputContent);
// }
//
//
// Future<String> getTranslation(String text, String lang) async {
// if (lang == defaultLang) return text;
// return (await translator.translate(text, from: defaultLang, to: lang)).text;
// }
//
// String getFileName(String lang) {
// final shortLang = lang
// .split("-")
// .first;
// return "./res/values/strings_$shortLang.arb";
// }

View file

@ -27,6 +27,24 @@ class S implements WidgetsLocalizations {
GeneratedLocalizationsDelegate();
static S of(BuildContext context) => Localizations.of<S>(context, S)!;
@override
String get reorderItemToStart => "reorderItemToStart";
@override
String get reorderItemToEnd => "reorderItemToEnd";
@override
String get reorderItemUp => "reorderItemUp";
@override
String get reorderItemDown => "reorderItemDown";
@override
String get reorderItemLeft => "reorderItemLeft";
@override
String get reorderItemRight => "reorderItemRight";
""";
const part2 = """