Skip to content

Commit

Permalink
changelog:
Browse files Browse the repository at this point in the history
improved translations
added one language
  • Loading branch information
gokadzev committed Jun 26, 2022
1 parent 9d77bdc commit 3f8df8e
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 66 deletions.
68 changes: 37 additions & 31 deletions lib/customWidgets/custom_animated_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ class CustomAnimatedBottomBar extends StatelessWidget {
splashColor: _selectedColor.withOpacity(0.1),
hoverColor: _selectedColor.withOpacity(0.1),
child: Padding(
padding: itemPadding -
(Directionality.of(context) == TextDirection.ltr
? EdgeInsets.only(
right: itemPadding.right * t)
: EdgeInsets.only(
left: itemPadding.left * t)),
padding: Localizations.localeOf(context) ==
Locale('en', '')
? itemPadding -
(Directionality.of(context) ==
TextDirection.ltr
? EdgeInsets.only(
right: itemPadding.right * t)
: EdgeInsets.only(
left: itemPadding.left * t))
: EdgeInsets.all(10.0),
child: Row(
children: [
IconTheme(
Expand All @@ -103,36 +107,38 @@ class CustomAnimatedBottomBar extends StatelessWidget {
? item.activeIcon ?? item.icon
: item.icon,
),
ClipRect(
clipBehavior: Clip.antiAlias,
child: SizedBox(
height: 20,
child: Align(
alignment: Alignment(-0.2, 0.0),
widthFactor: t,
child: Padding(
padding: Directionality.of(context) ==
TextDirection.ltr
? EdgeInsets.only(
left: itemPadding.left / 2,
right: itemPadding.right)
: EdgeInsets.only(
left: itemPadding.left,
right: itemPadding.right / 2),
child: DefaultTextStyle(
style: TextStyle(
color: Color.lerp(
_selectedColor.withOpacity(0.0),
_selectedColor,
t),
fontWeight: FontWeight.w600,
if (Localizations.localeOf(context) ==
Locale('en', ''))
ClipRect(
clipBehavior: Clip.antiAlias,
child: SizedBox(
height: 20,
child: Align(
alignment: Alignment(-0.2, 0.0),
widthFactor: t,
child: Padding(
padding: Directionality.of(context) ==
TextDirection.ltr
? EdgeInsets.only(
left: itemPadding.left / 2,
right: itemPadding.right)
: EdgeInsets.only(
left: itemPadding.left,
right: itemPadding.right / 2),
child: DefaultTextStyle(
style: TextStyle(
color: Color.lerp(
_selectedColor.withOpacity(0.0),
_selectedColor,
t),
fontWeight: FontWeight.w600,
),
child: item.title,
),
child: item.title,
),
),
),
),
),
],
),
),
Expand Down
4 changes: 4 additions & 0 deletions lib/localization/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"accentColor": "Accent color",
"add": "Add",
"appUpdateAvailableAndDownloading": "App update is available and downloading",
"appUpdateIsAvailable": "App update is available",
"appUpdateIsNotAvailable": "App update is not available",
"backupUserData": "Backup user data",
"backupedSuccesfully": "Backuped Succesfully",
"cacheMsg": "Cache cleared",
"clearCache": "Clear cache",
"downloadAppUpdate": "Download app update",
"home": "Home",
"language": "Language",
"languageMsg": "Language has been changed",
"localSongs": "Local songs",
"lyrics": "Lyrics",
"lyricsNotAvailable": "No lyrics available ;(",
Expand Down
36 changes: 36 additions & 0 deletions lib/localization/app_ka.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"about": "შესახებ",
"accentChangeMsg": "აქცენტის ფერი შეიცვალა, გადადით სხვა გვერძე ცვლილებების გამოსაჩენად",
"accentColor": "აქცენტის ფერი",
"add": "დამატება",
"appUpdateAvailableAndDownloading": "აპლიკაციის განახლება ხელმისაწვდომია და იტვირთება",
"appUpdateIsAvailable": "აპლიკაციის განახლება ხელმისაწვდომია",
"appUpdateIsNotAvailable": "აპლიკაციის განახლება არაა ხელმისაწვდომი",
"backupUserData": "მომხმარებლის ინფორმაციის დარეზერვება",
"backupedSuccesfully": "დარეზერვდა წარმატებით",
"cacheMsg": "ქეში გასუფთავდა",
"clearCache": "ქეშის გასუფთავება",
"downloadAppUpdate": "აპლიკაციის განახლების ჩამოტვირთვა",
"home": "მთავარი",
"language": "ენა",
"languageMsg": "ენა შეიცვალა",
"localSongs": "ადგილობრივი მუსიკა",
"lyrics": "ტექსტი",
"lyricsNotAvailable": "ტექსტი არაა ხელმისაწვდომი ;(",
"nowPlaying": "ახლა ჩართულია",
"playAll": "ყველას ჩართვა",
"playlist": "ფლეილისთი",
"playlists": "ფლეილისთები",
"queueInitText": "ხდება ინიციალიზება... აპლიკაციის სისწრაფის გამო, მხოლოდ პირველი 20 სიმღერა დაემატება დასაკრავ სიაში.",
"recommendedForYou": "შემოთავაზებები შენთვის",
"restoreUserData": "მომხმარებლის ინფორმაციის დაბრუნება",
"restoredSuccesfully": "წარმატებით დაბრუნდა",
"search": "ძიება",
"settings": "პარამეტრები",
"suggestedPlaylists": "შემოთავაზებული ფლეილისთები",
"userLikedSongs": "მომხმარებლის მოწონებული სიმღერები",
"userPlaylists": "მომხმარებლის ფლეილისთები",
"yourDownloadedSongsHere": "შენი გადმოწერილი სიმღერები აქ",
"yourFavoriteSongsHere": "შენი ფავორიტი სიმღერები აქ",
"youtubePlaylistID": "Youtube ფლეილისთის ID"
}
84 changes: 55 additions & 29 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,40 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

GetIt getIt = GetIt.instance;
Locale _locale = const Locale('en', '');

main() async {
await Hive.initFlutter();
final String lang = await getData("settings", "languages") ?? "English";
final Map<String, String> codes = {
'English': 'en',
};
_locale = Locale(codes[lang]!);
await getLocalSongs();
await FlutterDownloader.initialize(
debug:
true, // optional: set to false to disable printing logs to console (default: true)
ignoreSsl:
true // option: set to false to disable working with http links (default: false)
,
);
FlutterDownloader.registerCallback(TestClass.callback);
accent = await getData("settings", "accentColor") != null
? Color(await getData("settings", "accentColor") as int)
: const Color(0xFFFF9E80);
userPlaylists = await getData("user", "playlists") ?? [];
userLikedSongsList = await getData("user", "likedSongs") ?? [];
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
version = packageInfo.version;
await enableBooster();
initialisation();
runApp(MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

static void setLocale(BuildContext context, Locale newLocale) async {
_MyAppState state = context.findAncestorStateOfType<_MyAppState>()!;
state.changeLanguage(newLocale);
}

@override
_MyAppState createState() => _MyAppState();
}

class MyApp extends StatelessWidget {
class _MyAppState extends State<MyApp> {
Locale _locale = const Locale('en', '');

changeLanguage(Locale locale) {
setState(() {
_locale = locale;
});
}

@override
void initState() {
super.initState();
final String lang =
Hive.box('settings').get('language', defaultValue: 'English') as String;
final Map<String, String> codes = {
'English': 'en',
'Georgian': 'ka',
};
_locale = Locale(codes[lang]!);
}

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -69,13 +72,36 @@ class MyApp extends StatelessWidget {
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
supportedLocales: [Locale('en', ''), Locale('ka', '')],
locale: _locale,
home: Musify(),
);
}
}

main() async {
await Hive.initFlutter();
await getLocalSongs();
await FlutterDownloader.initialize(
debug:
true, // optional: set to false to disable printing logs to console (default: true)
ignoreSsl:
true // option: set to false to disable working with http links (default: false)
,
);
FlutterDownloader.registerCallback(TestClass.callback);
accent = await getData("settings", "accentColor") != null
? Color(await getData("settings", "accentColor") as int)
: const Color(0xFFFF9E80);
userPlaylists = await getData("user", "playlists") ?? [];
userLikedSongsList = await getData("user", "likedSongs") ?? [];
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
version = packageInfo.version;
await enableBooster();
initialisation();
runApp(MyApp());
}

Future<void> initialisation() async {
final AudioHandler audioHandler = await AudioService.init(
builder: () => MyAudioHandler(),
Expand Down
13 changes: 7 additions & 6 deletions lib/ui/rootPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:musify/ui/player.dart';
import 'package:musify/ui/playlistsPage.dart';
import 'package:musify/ui/searchPage.dart';
import 'package:musify/ui/settingsPage.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class Musify extends StatefulWidget {
@override
Expand Down Expand Up @@ -46,7 +47,7 @@ class AppState extends State<Musify> {
if (value == true)
{
Fluttertoast.showToast(
msg: "App Update Is Available!",
msg: "${AppLocalizations.of(context)!.appUpdateIsAvailable}!",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
backgroundColor: accent,
Expand Down Expand Up @@ -90,35 +91,35 @@ class AppState extends State<Musify> {
BottomNavBarItem(
icon: const Icon(MdiIcons.homeOutline),
activeIcon: const Icon(MdiIcons.home),
title: const Text('Home'),
title: Text(AppLocalizations.of(context)!.home),
activeColor: accent,
inactiveColor: Colors.white,
),
BottomNavBarItem(
icon: const Icon(MdiIcons.magnifyMinusOutline),
activeIcon: const Icon(MdiIcons.magnify),
title: const Text('Search'),
title: Text(AppLocalizations.of(context)!.search),
activeColor: accent,
inactiveColor: Colors.white,
),
BottomNavBarItem(
icon: const Icon(MdiIcons.bookOutline),
activeIcon: const Icon(MdiIcons.book),
title: const Text('Playlists'),
title: Text(AppLocalizations.of(context)!.playlists),
activeColor: accent,
inactiveColor: Colors.white,
),
BottomNavBarItem(
icon: const Icon(MdiIcons.downloadOutline),
activeIcon: const Icon(MdiIcons.download),
title: const Text('Local Songs'),
title: Text(AppLocalizations.of(context)!.localSongs),
activeColor: accent,
inactiveColor: Colors.white,
),
BottomNavBarItem(
icon: const Icon(MdiIcons.cogOutline),
activeIcon: const Icon(MdiIcons.cog),
title: const Text('Settings'),
title: Text(AppLocalizations.of(context)!.settings),
activeColor: accent,
inactiveColor: Colors.white,
)
Expand Down
Loading

0 comments on commit 3f8df8e

Please sign in to comment.