-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added sending and recieving tokens function
- Loading branch information
Showing
10 changed files
with
392 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:vidaia/main.dart'; | ||
import 'package:vidaia/pages/exchange/exchange_page_stack.dart'; | ||
import 'package:vidaia/pages/exchange/receive/recieve_page.dart'; | ||
import 'package:vidaia/pages/exchange/send/send_page.dart'; | ||
import 'package:vidaia/pages/home/history/buy_history_page.dart'; | ||
import 'package:vidaia/pages/home/home/home_page.dart'; | ||
import 'package:vidaia/pages/home/redeem/redeem_page.dart'; | ||
import 'package:vidaia/repositories/dataRepository.dart'; | ||
|
||
class ExchangePage extends StatefulWidget { | ||
ExchangePage({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<ExchangePage> createState() => _ExchangePageState(); | ||
} | ||
|
||
class _ExchangePageState extends State<ExchangePage> { | ||
late Future<bool> isDataLoaded; | ||
|
||
DataRepository dataRepository = getIt.get<DataRepository>(); | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
isDataLoaded = dataRepository.init(); | ||
} | ||
|
||
final _pages = [SendPage(), RecievePage()]; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FutureBuilder<bool>( | ||
future: isDataLoaded, | ||
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) { | ||
if (snapshot.connectionState == ConnectionState.done && snapshot.data == true) { | ||
return ExchangePageStack(_pages); | ||
} else if (snapshot.connectionState == ConnectionState.done && snapshot.hasError) { | ||
return Padding( | ||
padding: const EdgeInsets.only(top: 30), | ||
child: Text( | ||
'Error: ${snapshot.error}', | ||
style: TextStyle(fontSize: 20), | ||
), | ||
); | ||
} else { | ||
return Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Center( | ||
child: CircularProgressIndicator(), | ||
), | ||
SizedBox( | ||
height: 20, | ||
), | ||
Text( | ||
"Loading data", | ||
style: TextStyle(color: Colors.black38, fontSize: 15, fontWeight: FontWeight.w400), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:vidaia/utils/constants.dart'; | ||
import 'package:vidaia/utils/wallet.dart'; | ||
|
||
import '../../widgets/vidaia_drawer.dart'; | ||
|
||
class ExchangePageStack extends StatefulWidget { | ||
final List<Widget> list; | ||
|
||
ExchangePageStack(this.list); | ||
|
||
@override | ||
State<ExchangePageStack> createState() => _ExchangePageStackState(); | ||
} | ||
|
||
class _ExchangePageStackState extends State<ExchangePageStack> { | ||
int _selectedIndex = 0; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
} | ||
|
||
void _onItemTapped(int index) { | ||
setState(() { | ||
_selectedIndex = index; | ||
}); | ||
} | ||
|
||
var scaffoldKey = GlobalKey<ScaffoldState>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
backgroundColor: BACKGROUND, | ||
key: scaffoldKey, | ||
drawerEnableOpenDragGesture: false, | ||
appBar: AppBar( | ||
automaticallyImplyLeading: false, | ||
elevation: 0, | ||
backgroundColor: BACKGROUND, | ||
toolbarHeight: 90, | ||
title: Stack(alignment: AlignmentDirectional.centerEnd, children: [ | ||
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ | ||
Row( | ||
children: [ | ||
Container( | ||
padding: EdgeInsets.only( | ||
left: 5, | ||
), | ||
child: Image( | ||
image: AssetImage("assets/images/vidar.png"), | ||
height: 25, | ||
), | ||
), | ||
Container( | ||
padding: EdgeInsets.only( | ||
left: 5, | ||
), | ||
child: Text( | ||
'VID', | ||
style: TextStyle(color: Colors.black), | ||
), | ||
), | ||
], | ||
), | ||
StreamBuilder<BigInt>( | ||
//initialData: 0.0, | ||
stream: checkBalance(), | ||
builder: (context, snapshot) { | ||
switch (snapshot.connectionState) { | ||
case ConnectionState.waiting: | ||
return Container( | ||
width: 20, | ||
height: 20, | ||
child: CircularProgressIndicator( | ||
strokeWidth: 2, | ||
color: PRIMARY_LIGHT, | ||
)); | ||
default: | ||
if (snapshot.hasError) { | ||
return Text(snapshot.error.toString()); | ||
} else { | ||
final balance = snapshot.data.toString(); | ||
|
||
return Text(balance, | ||
style: TextStyle(color: PRIMARY_DARK, fontSize: 16)); | ||
} | ||
} | ||
}, | ||
), | ||
]), | ||
]), | ||
centerTitle: true, | ||
), | ||
bottomNavigationBar: BottomNavigationBar( | ||
selectedItemColor: PRIMARY, | ||
unselectedItemColor: SECONDARY, | ||
items: <BottomNavigationBarItem>[ | ||
BottomNavigationBarItem( | ||
icon: Container(), | ||
label: 'Send', | ||
), | ||
BottomNavigationBarItem( | ||
icon: Container(), | ||
label: 'Recieve'.tr() | ||
), | ||
], | ||
currentIndex: _selectedIndex, | ||
onTap: _onItemTapped, | ||
), | ||
body: IndexedStack( | ||
index: _selectedIndex, | ||
children: widget.list, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:vidaia/main.dart'; | ||
import 'package:vidaia/repositories/dataRepository.dart'; | ||
import 'package:qr_flutter/qr_flutter.dart'; | ||
import 'package:vidaia/utils/globals.dart'; | ||
|
||
class RecievePage extends StatefulWidget { | ||
const RecievePage({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<RecievePage> createState() => _RecievePageState(); | ||
} | ||
|
||
class _RecievePageState extends State<RecievePage> { | ||
DataRepository dataRepository = getIt.get<DataRepository>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
children: [ | ||
Expanded( | ||
child: Container(), | ||
), | ||
Column( | ||
children: [ | ||
Container(child: Text('Recieve')), | ||
QrImage( | ||
data: address!, | ||
size: 250, | ||
), | ||
Text(address!), | ||
TextButton( | ||
onPressed: () { | ||
Clipboard.setData(ClipboardData(text: address)); | ||
}, | ||
child: Text('Copy Address')), | ||
], | ||
), | ||
Expanded( | ||
child: Container(), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:mobile_scanner/mobile_scanner.dart'; | ||
import 'package:vidaia/utils/globals.dart' as global; | ||
|
||
class ScanPage extends StatefulWidget { | ||
const ScanPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<ScanPage> createState() => _ScanPageState(); | ||
} | ||
|
||
class _ScanPageState extends State<ScanPage> { | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MobileScanner( | ||
allowDuplicates: false, | ||
controller: MobileScannerController( | ||
facing: CameraFacing.back, torchEnabled: false), | ||
onDetect: (barcode, args) { | ||
final String code = barcode.rawValue!; | ||
global.qrCode = code; | ||
debugPrint('Barcode found! $code'); | ||
Navigator.pop(context); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import 'package:easy_localization/easy_localization.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:vidaia/main.dart'; | ||
import 'package:vidaia/pages/exchange/scan_page.dart'; | ||
import 'package:vidaia/repositories/dataRepository.dart'; | ||
import 'package:mobile_scanner/mobile_scanner.dart'; | ||
import 'package:vidaia/utils/globals.dart' as global; | ||
import 'package:vidaia/utils/wallet.dart'; | ||
|
||
import '../../../utils/constants.dart'; | ||
|
||
class SendPage extends StatefulWidget { | ||
const SendPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<SendPage> createState() => _SendPageState(); | ||
} | ||
|
||
class _SendPageState extends State<SendPage> { | ||
final addressController = TextEditingController(); | ||
final valueController = TextEditingController(); | ||
|
||
@override | ||
void dispose() { | ||
valueController.dispose(); | ||
addressController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
Material( | ||
type: MaterialType.transparency, | ||
child: ListTile( | ||
leading: const Icon( | ||
Icons.qr_code, | ||
color: PRIMARY_LIGHT, | ||
), | ||
title: Text( | ||
'Scan QRCode'.tr(), | ||
style: Theme.of(context).textTheme.subtitle1, | ||
), | ||
onTap: () { | ||
Navigator.push( | ||
context, | ||
MaterialPageRoute(builder: (context) => ScanPage()), | ||
); | ||
}, | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: TextField( | ||
|
||
decoration: InputDecoration( | ||
border: OutlineInputBorder(), | ||
hintText: "Receiver's Address", | ||
), | ||
controller: addressController, | ||
), | ||
), | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: TextField( | ||
decoration: InputDecoration( | ||
border: OutlineInputBorder(), | ||
hintText: 'Amount', | ||
), | ||
controller: valueController, | ||
), | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
addressController.text = '0x00bab3d8de4ebbefb07d53b1ff8c0f2434bd616d'; | ||
}, | ||
child: Text('set address')), | ||
ElevatedButton( | ||
onPressed: () { | ||
transferVidar(int.parse(valueController.text), | ||
addressController.text, 'https://testnet.veblocks.net'); | ||
}, | ||
child: Text('Send')), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.