Skip to content

Commit

Permalink
Remove double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhzdhd committed Jun 11, 2023
1 parent 8ccc4c9 commit 151b224
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 82 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ linter:
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
prefer_single_quotes: true

analyzer:
errors:
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="msauth" android:host="com.example.syncvault"/>
<data android:scheme="https" android:host="com.example.syncvault"/>
<data android:scheme="https"/>
</intent-filter>
</activity>

Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void main() async {
await systemTray.setContextMenu(menu);

systemTray.registerSystemTrayEventHandler((eventName) {
debugPrint("eventName: $eventName");
debugPrint('eventName: $eventName');
if (eventName == kSystemTrayEventClick) {
Platform.isWindows ? appWindow.show() : systemTray.popUpContextMenu();
} else if (eventName == kSystemTrayEventRightClick) {
Expand Down
120 changes: 60 additions & 60 deletions lib/src/accounts/services/auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,33 @@ abstract interface class AuthService {
}

final class DropBoxAuth implements AuthService {
static const clientId = "ma42r73plfcdnrf";
static const clientId = 'ma42r73plfcdnrf';
static final callbackUrlScheme = Platform.isAndroid
? 'https://www.dropbox.com/1/oauth2/redirect_receiver'
: 'http://localhost:8006';
static const apiHost = "api.dropboxapi.com";
static const authHost = "www.dropbox.com";
static const apiHost = 'api.dropboxapi.com';
static const authHost = 'www.dropbox.com';

@override
Future<Either<String, AuthProviderModel>> signIn() async {
final codeUri = Uri.https(
authHost,
"/oauth2/authorize",
'/oauth2/authorize',
{
"client_id": clientId,
"response_type": "code",
"redirect_uri": callbackUrlScheme,
"scope": "files.content.read files.content.write account_info.read",
"state": "12345",
"token_access_type": "offline",
'client_id': clientId,
'response_type': 'code',
'redirect_uri': callbackUrlScheme,
'scope': 'files.content.read files.content.write account_info.read',
'state': '12345',
'token_access_type': 'offline',
},
);

late final String result;
if (Platform.isAndroid) {
result = await FlutterWebAuth2.authenticate(
url: codeUri.toString(),
callbackUrlScheme: 'msauth',
callbackUrlScheme: 'https',
preferEphemeral: true,
);
} else {
Expand All @@ -62,25 +62,25 @@ final class DropBoxAuth implements AuthService {
);

final options = Options(
headers: {"Content-Type": "application/x-www-form-urlencoded"},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
);
final response = await dio.postUri<Map<String, dynamic>>(
tokenUri,
data: {
"client_id": clientId,
"client_secret": "",
"code": code,
"grant_type": "authorization_code",
"redirect_uri": callbackUrlScheme,
'client_id': clientId,
'client_secret': '',
'code': code,
'grant_type': 'authorization_code',
'redirect_uri': callbackUrlScheme,
},
options: options,
);

final accessToken = response.data!["access_token"];
final accessToken = response.data!['access_token'];
final user = await getUserInfo(accessToken);
final drive = await getDriveInfo(accessToken);
final remainingStorage =
(drive["allocation"]["allocated"] as int) - (drive["used"] as int);
(drive['allocation']['allocated'] as int) - (drive['used'] as int);

final folderIdResult = await DropBox()
.createFolder(
Expand All @@ -93,14 +93,14 @@ final class DropBoxAuth implements AuthService {
return folderIdResult.map(
(id) => AuthProviderModel(
accessToken: accessToken,
refreshToken: response.data!["refresh_token"],
expiresIn: response.data!["expires_in"],
refreshToken: response.data!['refresh_token'],
expiresIn: response.data!['expires_in'],
provider: AuthProviderType.dropBox,
email: user["email"],
name: user["name"]["display_name"],
email: user['email'],
name: user['name']['display_name'],
createdAt: DateTime.now().toIso8601String(),
remainingStorage: remainingStorage,
usedStorage: drive["used"],
usedStorage: drive['used'],
folderId: id,
),
);
Expand All @@ -114,7 +114,7 @@ final class DropBoxAuth implements AuthService {
@override
Future<Map<String, dynamic>> getUserInfo(String accessToken) async {
final authOptions = Options(headers: {
"Authorization": "Bearer $accessToken",
'Authorization': 'Bearer $accessToken',
});

final uri = Uri.https(apiHost, '/2/users/get_current_account');
Expand All @@ -129,7 +129,7 @@ final class DropBoxAuth implements AuthService {
@override
Future<Map<String, dynamic>> getDriveInfo(String accessToken) async {
final authOptions = Options(headers: {
"Authorization": "Bearer $accessToken",
'Authorization': 'Bearer $accessToken',
});

final uri = Uri.https(apiHost, '/2/users/get_space_usage');
Expand All @@ -143,25 +143,25 @@ final class DropBoxAuth implements AuthService {
}

final class OneDriveAuth implements AuthService {
static const clientId = "591486db-4bcc-46b7-ad21-45a6c59cfa26";
static const clientId = '591486db-4bcc-46b7-ad21-45a6c59cfa26';
static final callbackUrlScheme = Platform.isAndroid
? "msauth://com.example.syncvault/mf%2BaFV5Ps1q90nV2hXuUBpjGfXo%3D"
? 'msauth://com.example.syncvault/mf%2BaFV5Ps1q90nV2hXuUBpjGfXo%3D'
: 'http://localhost:8006';
static const apiHost = "graph.microsoft.com";
static const authHost = "login.microsoftonline.com";
static const apiHost = 'graph.microsoft.com';
static const authHost = 'login.microsoftonline.com';

@override
Future<Either<String, AuthProviderModel>> signIn() async {
final codeUri = Uri.https(
authHost,
"/common/oauth2/v2.0/authorize",
'/common/oauth2/v2.0/authorize',
{
"client_id": clientId,
"response_type": "code",
"redirect_uri": callbackUrlScheme,
"response_mode": "query",
"scope": "offline_access files.readwrite.all user.read",
"state": "12345",
'client_id': clientId,
'response_type': 'code',
'redirect_uri': callbackUrlScheme,
'response_mode': 'query',
'scope': 'offline_access files.readwrite.all user.read',
'state': '12345',
},
);

Expand All @@ -187,21 +187,21 @@ final class OneDriveAuth implements AuthService {
);

final options = Options(
headers: {"Content-Type": "application/x-www-form-urlencoded"},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
);
final response = await dio.postUri<Map<String, dynamic>>(
tokenUri,
data: {
"client_id": clientId,
"code": code,
"grant_type": "authorization_code",
"scope": "offline_access files.readwrite.all user.read",
"redirect_uri": callbackUrlScheme,
'client_id': clientId,
'code': code,
'grant_type': 'authorization_code',
'scope': 'offline_access files.readwrite.all user.read',
'redirect_uri': callbackUrlScheme,
},
options: options,
);

final accessToken = response.data!["access_token"];
final accessToken = response.data!['access_token'];
final user = await getUserInfo(accessToken);
final drive = await getDriveInfo(accessToken);

Expand All @@ -216,14 +216,14 @@ final class OneDriveAuth implements AuthService {
return folderIdResult.map(
(id) => AuthProviderModel(
accessToken: accessToken,
refreshToken: response.data!["refresh_token"],
expiresIn: response.data!["expires_in"],
refreshToken: response.data!['refresh_token'],
expiresIn: response.data!['expires_in'],
provider: AuthProviderType.oneDrive,
email: user["mail"],
name: user["displayName"],
email: user['mail'],
name: user['displayName'],
createdAt: DateTime.now().toIso8601String(),
remainingStorage: drive["quota"]["remaining"],
usedStorage: drive["quota"]["used"],
remainingStorage: drive['quota']['remaining'],
usedStorage: drive['quota']['used'],
folderId: id,
),
);
Expand All @@ -237,26 +237,26 @@ final class OneDriveAuth implements AuthService {

if (diff <= 0) {
final options = Options(
headers: {"Content-Type": "application/x-www-form-urlencoded"},
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
);
final uri = Uri.https(authHost, '/common/oauth2/v2.0/token');
final response = await dio.postUri<Map<String, dynamic>>(
uri,
data: {
"client_id": clientId,
"grant_type": "refresh_token",
"scope": "offline_access files.readwrite.all user.read",
"refresh_token": model.refreshToken,
'client_id': clientId,
'grant_type': 'refresh_token',
'scope': 'offline_access files.readwrite.all user.read',
'refresh_token': model.refreshToken,
},
options: options,
);

// print(response.data!["access_token"]);

return model.copyWith(
accessToken: response.data!["access_token"],
expiresIn: response.data!["expires_in"],
refreshToken: response.data!["refresh_token"],
accessToken: response.data!['access_token'],
expiresIn: response.data!['expires_in'],
refreshToken: response.data!['refresh_token'],
);
} else {
return model;
Expand All @@ -266,7 +266,7 @@ final class OneDriveAuth implements AuthService {
@override
Future<Map<String, dynamic>> getUserInfo(String accessToken) async {
final authOptions = Options(headers: {
"Authorization": "Bearer $accessToken",
'Authorization': 'Bearer $accessToken',
});

final uri = Uri.https(apiHost, '/beta/me');
Expand All @@ -281,7 +281,7 @@ final class OneDriveAuth implements AuthService {
@override
Future<Map<String, dynamic>> getDriveInfo(String accessToken) async {
final authOptions = Options(headers: {
"Authorization": "Bearer $accessToken",
'Authorization': 'Bearer $accessToken',
});

final uri = Uri.https(apiHost, '/beta/me/drive');
Expand Down
34 changes: 17 additions & 17 deletions lib/src/accounts/services/drive_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ abstract interface class DriveService {
}

class DropBox implements DriveService {
static const apiHost = "api.dropbox.com";
static const basePath = "/2/files";
static const apiHost = 'api.dropbox.com';
static const basePath = '/2/files';

@override
TaskEither<String, String> createFolder({
Expand All @@ -33,8 +33,8 @@ class DropBox implements DriveService {
}) {
final uri = Uri.https(apiHost, '$basePath/create_folder_v2');
final authOptions = Options(headers: {
"Authorization": "Bearer $accessToken",
"Content-Type": "application/json"
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json'
});

return TaskEither.tryCatch(
Expand All @@ -43,14 +43,14 @@ class DropBox implements DriveService {
uri,
options: authOptions,
data: {
"autorename": true,
"path": folderName.match(
'autorename': true,
'path': folderName.match(
() => '/SyncVault',
(t) => '/SyncVault/$t',
),
},
);
return response.data!["metadata"]["id"];
return response.data!['metadata']['id'];
},
(error, stackTrace) => error.toString(),
);
Expand All @@ -69,8 +69,8 @@ class DropBox implements DriveService {
}

class OneDrive implements DriveService {
static const apiHost = "graph.microsoft.com";
static const basePath = "/beta/me/drive";
static const apiHost = 'graph.microsoft.com';
static const basePath = '/beta/me/drive';

@override
TaskEither<String, String> createFolder({
Expand All @@ -81,8 +81,8 @@ class OneDrive implements DriveService {
final subPath = folderId.match(() => 'root', (t) => 'items/$t');
final uri = Uri.https(apiHost, '$basePath/$subPath/children');
final authOptions = Options(headers: {
"Authorization": "Bearer $accessToken",
"Content-Type": "application/json"
'Authorization': 'Bearer $accessToken',
'Content-Type': 'application/json'
});

return TaskEither.tryCatch(
Expand All @@ -91,11 +91,11 @@ class OneDrive implements DriveService {
uri,
options: authOptions,
data: {
"name": folderName.match(() => 'SyncVault', (t) => t),
"folder": {"childCount": 0}
'name': folderName.match(() => 'SyncVault', (t) => t),
'folder': {'childCount': 0}
},
);
return response.data!["id"];
return response.data!['id'];
},
(error, stackTrace) => error.toString(),
);
Expand All @@ -107,8 +107,8 @@ class OneDrive implements DriveService {
Option<String> filePath,
) {
final authOptions = Options(headers: {
"Authorization": "Bearer ${authModel.accessToken}",
"Content-Type": "application/json"
'Authorization': 'Bearer ${authModel.accessToken}',
'Content-Type': 'application/json'
});

final folder = Directory(folderModel.folderPath);
Expand Down Expand Up @@ -159,7 +159,7 @@ class OneDrive implements DriveService {
uri,
options: authOptions,
data: {
'item': {"@microsoft.graph.conflictBehavior": "replace"},
'item': {'@microsoft.graph.conflictBehavior': 'replace'},
},
);

Expand Down
2 changes: 0 additions & 2 deletions lib/src/accounts/views/account_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class AccountView extends ConsumerWidget {
),
],
),

// const Spacer(),
// Stack(
// children: [
Expand All @@ -110,7 +109,6 @@ class AccountView extends ConsumerWidget {
// height: 75,
// child: CircularProgressIndicator(
// value: e.usedStorage / e.remainingStorage,
// backgroundColor: Colors.deepPurple,
// ),
// ),
// ],
Expand Down

0 comments on commit 151b224

Please sign in to comment.