Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated hardcoded strings to strings.dart #61

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
24 changes: 24 additions & 0 deletions lib/model/strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,27 @@ var fileLocation = 'File Location';
var fileName = 'File Name';
var clipBoardYT = 'Clipboard doesn\'t contain a valid YouTube video URL';
var openValidVideo = 'Please open a YouTube Video to download';
var darktheme='Dark Theme';
var refreshingDB='Refreshing DB';
var newSongs='Looking for new songs';
var refreshSongs='Refresh Songs';
var songsRemoved=' songs removed';
var newSongsAdded=' new songs added';
var noNewMusic='No music files found :(';
var loading='Loading';
var willBeStored='Downloaded files will be stored to \nAndroid/Data/in.amfoss.raag/files\nUse a File manager to move to your preferred location';
var y='Downloaded files will be stored to \nDownload/Raag/';
var downloadedLocation='Download Location';
var d='Storage/Download/Raag';
var e='Android/Data/in.amfoss.raag/files/';
var settings='Settings';
var noPageHistory='No page in history';
var noForward='No page to go forward';
var millenium='The Millennial\'s music app';
var allSongs='Listen to all your songs in one place';
var youtube='YouTube to your device. No strings';
var skip='Skip';
var unkownError='Unknown error';
var cancel='Cancel';
var unable='Raag was unable to create a file. Try changing the download location from settings and try again';
var downloadMus='Download music';
16 changes: 8 additions & 8 deletions lib/view/download_music.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';

import 'package:clipboard/clipboard.dart';
import 'package:downloads_path_provider_28/downloads_path_provider_28.dart';
import 'package:flutter/material.dart';
Expand All @@ -10,7 +9,6 @@ import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
import 'package:raag/model/SharedPreferences.dart';
import 'package:raag/model/connectivity.dart';
import 'package:raag/model/strings.dart';
import 'package:raag/provider/audio_helper.dart';
import 'package:raag/provider/settings_provider.dart';
import 'package:raag/provider/theme.dart';
Expand All @@ -19,6 +17,8 @@ import 'package:raag/view/settings.dart';
import 'package:raag/view/youtube_search.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
import 'package:raag/model/strings.dart';


class DownloadMusic extends StatefulWidget {
final String url;
Expand Down Expand Up @@ -136,7 +136,6 @@ class _DownloadMusicState extends State<DownloadMusic> {
.replaceAll('.', ' ')
.replaceAll('/', ' ')
.replaceAll(':', ' ');
//TODO Do something efficient to choose only alpha-numeric characters from $title
var filePath = _raagDownloadsDirectory.path + '/' + tempTitle + '.mp3';

if (streamInfo != null) {
Expand Down Expand Up @@ -170,14 +169,14 @@ class _DownloadMusicState extends State<DownloadMusic> {
context: context,
title: 'File error',
desc:
'Raag was unable to create a file. Try changing the download location from settings and try again',
unable,
type: AlertType.error,
style: Styles.alertStyle(context),
buttons: [
DialogButton(
color: Theme.of(context).colorScheme.secondary,
child: Text(
"Settings",
settings,
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () {
Expand All @@ -193,7 +192,7 @@ class _DownloadMusicState extends State<DownloadMusic> {
DialogButton(
color: Theme.of(context).colorScheme.secondary,
child: Text(
"Cancel",
cancel,
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context))
Expand All @@ -206,7 +205,7 @@ class _DownloadMusicState extends State<DownloadMusic> {
print("Exception: $e\nStack Trace: $s");
Alert(
context: context,
title: 'Unknown error',
title: unkownError,
desc: '$e',
type: AlertType.error,
style: Styles.alertStyle(context))
Expand All @@ -233,7 +232,8 @@ class _DownloadMusicState extends State<DownloadMusic> {
leading: IconButton(
icon: Icon(Icons.arrow_back_ios_outlined),
onPressed: () => Navigator.pop(context)),
title: Text("Download music",
title: Text(
downloadMus,
style: Theme.of(context).textTheme.headline3),
centerTitle: true,
actions: [
Expand Down
1 change: 0 additions & 1 deletion lib/view/home_scaffold.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:raag/provider/settings_provider.dart';
Expand Down
10 changes: 5 additions & 5 deletions lib/view/onboarding.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:raag/model/strings.dart';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a duplicate import

import 'package:raag/provider/theme.dart';
import 'package:raag/widgets/intro_widget.dart';
import 'package:raag/model/strings.dart';

import 'home_scaffold.dart';

Expand Down Expand Up @@ -54,23 +54,23 @@ class _OnBoardingState extends State<OnBoarding> {
type: appName,
startGradientColor: Theme.of(context).colorScheme.secondary,
endGradientColor: Colors.deepPurple,
subText: 'The Millennial\'s music app'),
subText: millenium),
IntroWidget(
screenWidth: screenWidth,
screenHeight: screenHeight,
image: 'assets/images/onBoarding2.png',
type: 'Listen',
startGradientColor: hex('407BFF'),
endGradientColor: hex('004DFF'),
subText: 'Listen to all your songs in one place'),
subText: allSongs),
IntroWidget(
screenWidth: screenWidth,
screenHeight: screenHeight,
image: 'assets/images/onBoarding3.png',
type: 'Download',
startGradientColor: hex('FF725E'),
endGradientColor: hex('FF1A00'),
subText: 'YouTube to your device. No strings'),
subText: youtube),
];

List<Widget> _buildPageIndicator() {
Expand Down Expand Up @@ -120,7 +120,7 @@ class _OnBoardingState extends State<OnBoarding> {
curve: Curves.ease);
},
child: Text(
'Skip',
skip,
style: Theme.of(context).textTheme.headline3,
)),
),
Expand Down
3 changes: 2 additions & 1 deletion lib/view/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:raag/provider/settings_provider.dart';
import 'package:raag/widgets/download_location_button_settings.dart';
import 'package:raag/widgets/refresh_button.dart';
import 'package:raag/widgets/theme_button.dart';
import 'package:raag/model/strings.dart';

class Settings extends StatelessWidget {
@override
Expand All @@ -27,7 +28,7 @@ class Settings extends StatelessWidget {
pinned: true,
snap: true,
flexibleSpace: FlexibleSpaceBar(
title: Text('Settings',
title: Text(settings,
style: Theme.of(context).textTheme.headline1),
),
),
Expand Down
6 changes: 3 additions & 3 deletions lib/view/youtube_search.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:async';
import 'dart:io';

import 'package:raag/model/strings.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
Expand Down Expand Up @@ -131,7 +131,7 @@ class NavigationControls extends StatelessWidget {
if (await controller.canGoBack()) {
await controller.goBack();
} else {
Fluttertoast.showToast(msg: 'No page in history');
Fluttertoast.showToast(msg: noPageHistory);
}
},
),
Expand All @@ -143,7 +143,7 @@ class NavigationControls extends StatelessWidget {
if (await controller.canGoForward()) {
await controller.goForward();
} else {
Fluttertoast.showToast(msg: 'No page to go forward');
Fluttertoast.showToast(msg: noForward);
}
},
),
Expand Down
11 changes: 6 additions & 5 deletions lib/widgets/download_location_button_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import 'package:raag/provider/settings_provider.dart';
import 'package:raag/model/strings.dart';

class DownloadLocationButton extends StatelessWidget {
@override
Expand All @@ -17,11 +18,11 @@ class DownloadLocationButton extends StatelessWidget {
provider.appStorage = false;
Fluttertoast.showToast(
msg:
'Downloaded files will be stored to \nAndroid/Data/in.amfoss.raag/files\nUse a File manager to move to your preferred location',
willBeStored,
toastLength: Toast.LENGTH_LONG);
} else {
Fluttertoast.showToast(
msg: 'Downloaded files will be stored to \nDownload/Raag/',
msg: y,
toastLength: Toast.LENGTH_LONG);
provider.appStorage = true;
}
Expand All @@ -43,13 +44,13 @@ class DownloadLocationButton extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Download Location',
downloadedLocation,
style: Theme.of(context).textTheme.headline3,
),
Text(
provider.appStorage == true
? 'Storage/Download/Raag'
: 'Android/Data/in.amfoss.raag/files/',
? d
: e,
style: Theme.of(context).textTheme.subtitle2,
)
],
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/loading_indicator.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:raag/model/strings.dart';

class LoadingIndicator extends StatelessWidget {
@override
Expand All @@ -22,7 +23,7 @@ class LoadingIndicator extends StatelessWidget {
width: 20,
),
Text(
"Loading",
loading,
style: Theme.of(context).textTheme.headline3,
)
],
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/my_music_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:raag/model/music_model.dart';
import 'package:raag/provider/db_provider.dart';
import 'package:raag/widgets/loading_indicator.dart';
import 'package:raag/widgets/song_widget.dart';
import 'package:raag/model/strings.dart';

class MyMusicList extends StatelessWidget {
@override
Expand All @@ -18,7 +19,7 @@ class MyMusicList extends StatelessWidget {
} else if (songInfo?.isEmpty ?? true) {
return Center(
child: Text(
'No music files found :(',
noNewMusic,
style: Theme.of(context).textTheme.subtitle1,
));
}
Expand Down
9 changes: 5 additions & 4 deletions lib/widgets/refresh_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:raag/provider/db_provider.dart';
import 'package:raag/view/splash_screen.dart';
import 'package:raag/model/strings.dart';

class RefreshButton extends StatelessWidget {
@override
Expand All @@ -15,10 +16,10 @@ class RefreshButton extends StatelessWidget {
return AlertDialog(
backgroundColor: Theme.of(context).backgroundColor,
title: Text(
'Refreshing DB',
refreshingDB,
style: Theme.of(context).textTheme.headline3,
),
content: Text('Looking for new songs'));
content: Text(newSongs));
},
);
}
Expand All @@ -32,7 +33,7 @@ class RefreshButton extends StatelessWidget {
// _preferencesProvider.setBool(Preferences.DB_POPULATED, false);
await SplashScreen.populateSongsIntoDB();
var _diff = await DBProvider.db.getCount() - _oldCount;
var toastText = (_diff < 0) ? ' songs removed' : ' new songs added';
var toastText = (_diff < 0) ? songsRemoved : newSongsAdded;
Navigator.of(context).pop();
Fluttertoast.showToast(msg: (_diff).toString() + toastText);
},
Expand All @@ -50,7 +51,7 @@ class RefreshButton extends StatelessWidget {
width: screenWidth * 0.04,
),
Text(
'Refresh Songs',
refreshSongs,
style: Theme.of(context).textTheme.headline3,
)
]),
Expand Down
5 changes: 2 additions & 3 deletions lib/widgets/theme_button.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:animated_icon_button/animated_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:provider/provider.dart';
import 'package:raag/provider/settings_provider.dart';
import 'package:raag/provider/theme.dart';

import 'package:raag/model/strings.dart';
class ThemeButton extends StatefulWidget {
@override
_ThemeButtonState createState() => _ThemeButtonState();
Expand Down Expand Up @@ -65,7 +64,7 @@ class _ThemeButtonState extends State<ThemeButton>
width: screenWidth * 0.04,
),
Text(
'Dark Theme',
darktheme,
style: Theme.of(context).textTheme.headline3,
),
SizedBox(
Expand Down
Loading