Skip to content

Commit

Permalink
Merge pull request #25 from k5924/HP-65
Browse files Browse the repository at this point in the history
HP-65: Started Implementing Binance API
  • Loading branch information
k5924 authored Mar 3, 2022
2 parents 3660e9d + 378d59c commit 76b897f
Show file tree
Hide file tree
Showing 21 changed files with 450 additions and 170 deletions.
40 changes: 40 additions & 0 deletions lib/src/providers/binance_exchange_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:monerate/src/providers/export.dart';

class BinanceExchangeProvider {
final String url = "api.binance.com";

String _hmacSha256(String query, String secret) {
final key = utf8.encode(secret);
final msg = utf8.encode(query);
final hmac = Hmac(sha256, key);
final signature = hmac.convert(msg).toString();

return signature;
}

Future getBalances(String secret, String apiKey) async {
final String timestamp =
"timestamp=${DateTime.now().millisecondsSinceEpoch}";
final String query = '' + '&' + timestamp;
final String signature = _hmacSha256(query, secret);
final ExternalAPIProvider externalAPIProvider = ExternalAPIProvider(
url: url,
endPoint: '/api/v3/account',
parameters: {
'?': query,
'&signature': signature,
},
headers: {
'X-MBX-APIKEY': apiKey,
},
);
final cryptoBalances = await externalAPIProvider.getData();
if (cryptoBalances.runtimeType == int) {
return "error";
} else {
return cryptoBalances;
}
}
}
1 change: 1 addition & 0 deletions lib/src/providers/export.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// this is the export file for the providers folder
export 'auth_provider.dart';
export 'binance_exchange_provider.dart';
export 'database_provider.dart';
export 'external_api_provider.dart';
export 'remote_config_provider.dart';
Expand Down
167 changes: 4 additions & 163 deletions lib/src/screens/complete_profile/complete_profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,169 +35,10 @@ class _CompleteProfileScreenState extends State<CompleteProfileScreen> {
onPageChanged: (index) {
setState(() => _currentIndex = index);
},
children: [
Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"End-user",
style: Theme.of(context).textTheme.headline3,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
Image.asset(
'assets/images/End-user complete profile.png',
),
const SizedBox(
height: 25,
),
Text(
"I want to manage my finances",
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
context,
CompleteEndUserProfile.kID,
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 10,
),
),
child: const Text(
"Complete Profile",
style: TextStyle(
fontSize: 24,
),
),
),
],
),
),
),
),
Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Financial Advisor",
style: Theme.of(context).textTheme.headline3,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
Image.asset(
'assets/images/Financial Advisor complete profile.png',
),
const SizedBox(
height: 25,
),
Text(
"I want to give individuals financial advice",
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
context,
CompleteFinancialAdvisorProfile.kID,
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 10,
),
),
child: const Text(
"Complete Profile",
style: TextStyle(
fontSize: 24,
),
),
),
],
),
),
),
),
Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Support Manager",
style: Theme.of(context).textTheme.headline3,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
Image.asset(
'assets/images/Support Manager Complete Profile.png',
),
const SizedBox(
height: 25,
),
Text(
"I want to help people use the application",
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
context,
CompleteSupportManagerProfile.kID,
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 10,
),
),
child: const Text(
"Complete Profile",
style: TextStyle(
fontSize: 24,
),
),
),
],
),
),
),
)
children: const [
EndUserTab(),
FinancialAdvisorTab(),
SupportManagerTab()
],
),
),
Expand Down
70 changes: 70 additions & 0 deletions lib/src/screens/complete_profile/end_user/end_user_tab.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';

import 'package:monerate/src/screens/complete_profile/end_user/export.dart';

class EndUserTab extends StatefulWidget {
const EndUserTab({Key? key}) : super(key: key);

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

class _EndUserTabState extends State<EndUserTab> {
@override
Widget build(BuildContext context) {
return Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"End-user",
style: Theme.of(context).textTheme.headline3,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
Image.asset(
'assets/images/End-user complete profile.png',
),
const SizedBox(
height: 25,
),
Text(
"I want to manage my finances",
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
context,
CompleteEndUserProfile.kID,
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 10,
),
),
child: const Text(
"Complete Profile",
style: TextStyle(
fontSize: 24,
),
),
),
],
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions lib/src/screens/complete_profile/end_user/export.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'complete_end_user_profile.dart';
export 'end_user_tab.dart';
6 changes: 3 additions & 3 deletions lib/src/screens/complete_profile/export.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export 'complete_end_user_profile.dart';
export 'complete_financial_advisor_profile.dart';
export 'complete_profile_screen.dart';
export 'complete_support_manager_profile.dart';
export 'end_user/export.dart';
export 'financial_advisor/export.dart';
export 'support_manager/export.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'complete_financial_advisor_profile.dart';
export 'financial_advisor_tab.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';

import 'package:monerate/src/screens/complete_profile/financial_advisor/export.dart';

class FinancialAdvisorTab extends StatefulWidget {
const FinancialAdvisorTab({Key? key}) : super(key: key);

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

class _FinancialAdvisorTabState extends State<FinancialAdvisorTab> {
@override
Widget build(BuildContext context) {
return Center(
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Financial Advisor",
style: Theme.of(context).textTheme.headline3,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
Image.asset(
'assets/images/Financial Advisor complete profile.png',
),
const SizedBox(
height: 25,
),
Text(
"I want to give individuals financial advice",
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
),
const SizedBox(
height: 25,
),
ElevatedButton(
onPressed: () {
Navigator.pushNamed(
context,
CompleteFinancialAdvisorProfile.kID,
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 40,
vertical: 10,
),
),
child: const Text(
"Complete Profile",
style: TextStyle(
fontSize: 24,
),
),
),
],
),
),
),
);
}
}
3 changes: 3 additions & 0 deletions lib/src/screens/complete_profile/support_manager/export.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export 'complete_support_manager_profile.dart';
export 'support_manager_tab.dart';

Loading

0 comments on commit 76b897f

Please sign in to comment.