Skip to content

Commit

Permalink
ui: added mintnft button, fixed typography, recfator code
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiggle committed Apr 2, 2024
1 parent ea7351b commit c08d89f
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 116 deletions.
13 changes: 13 additions & 0 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ PODS:
- Flutter (1.0.0)
- flutter_native_splash (0.0.1):
- Flutter
- fluttertoast (0.0.2):
- Flutter
- Toast
- passkeys_ios (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
Expand All @@ -10,6 +13,7 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- Toast (4.1.0)
- ua_client_hints (1.2.2):
- Flutter
- web3_signers (0.0.1):
Expand All @@ -18,17 +22,24 @@ PODS:
DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- passkeys_ios (from `.symlinks/plugins/passkeys_ios/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- ua_client_hints (from `.symlinks/plugins/ua_client_hints/ios`)
- web3_signers (from `.symlinks/plugins/web3_signers/ios`)

SPEC REPOS:
trunk:
- Toast

EXTERNAL SOURCES:
Flutter:
:path: Flutter
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
passkeys_ios:
:path: ".symlinks/plugins/passkeys_ios/ios"
path_provider_foundation:
Expand All @@ -43,9 +54,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
passkeys_ios: fdae8c06e2178a9fcb9261a6cb21fb9a06a81d53
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
Toast: ec33c32b8688982cecc6348adeae667c1b9938da
ua_client_hints: 7f4e0f5d390685e8f7efd6eb363594f760108926
web3_signers: 5f49d582ab0d1fe673b3220aa6ecf25bb3cbed6b

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'package:variancedemo/providers/wallet_provider.dart';
import 'package:variancedemo/screens/create_account.dart';
import 'package:variancedemo/screens/home_screen.dart';
import 'package:variancedemo/screens/home/home_screen.dart';

final globalScaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();

Expand Down
16 changes: 8 additions & 8 deletions example/lib/providers/wallet_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:web3_signers/web3_signers.dart';
import 'package:variance_dart/variance.dart';
import 'package:web3dart/credentials.dart';
Expand All @@ -14,11 +13,12 @@ class WalletProvider extends ChangeNotifier {

SmartWallet? _wallet;
SmartWallet? get wallet => _wallet;
String? _error;
String? get errorMessage => _error;

String _errorMessage = "";
String get errorMessage => _errorMessage;

WalletProvider()
: _chain = Chains.getChain(Network.baseTestent)
: _chain = Chains.getChain(Network.baseTestnet)
..accountFactory = EthereumAddress.fromHex(
"0x402A266e92993EbF04a5B3fd6F0e2b21bFC83070")
..bundlerUrl =
Expand Down Expand Up @@ -52,9 +52,9 @@ class WalletProvider extends ChangeNotifier {

log("wallet created ${_wallet?.address.hex} ");
} catch (e) {
log("something happened: $e");
_error = e.toString();
_errorMessage = e.toString();
notifyListeners();
log("something happened: $e");
}
}

Expand All @@ -77,11 +77,11 @@ class WalletProvider extends ChangeNotifier {
log("wallet created ${_wallet?.address.hex} ");
} catch (e) {
log("something happened: $e");
_error = e.toString();
notifyListeners();
}
}

Future<void> mintNFt() async {}

Future<void> sendTransaction(String recipient, String amount) async {
if (_wallet != null) {
final etherAmount =
Expand Down
5 changes: 2 additions & 3 deletions example/lib/screens/create_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:fluttertoast/fluttertoast.dart';
import 'package:provider/provider.dart';
import 'package:variancedemo/main.dart';
import 'package:variancedemo/providers/wallet_provider.dart';
import 'package:variancedemo/utils/widgets.dart';

class CreateAccountScreen extends StatefulWidget {
const CreateAccountScreen({super.key});
Expand Down Expand Up @@ -95,10 +94,10 @@ class _CreateAccountScreenState extends State<CreateAccountScreen> {
await value.registerWithPassKey(controller.text,
requiresUserVerification: true);
// ignore: use_build_context_synchronously
if (value.errorMessage != null) {
if (value.errorMessage.isNotEmpty) {
fToast?.showToast(
gravity: ToastGravity.BOTTOM,
child: Text(value.errorMessage!));
child: Text(value.errorMessage));
} else {
Navigator.pushNamed(context, '/home');
}
Expand Down
123 changes: 123 additions & 0 deletions example/lib/screens/home/home_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import 'package:variancedemo/providers/wallet_provider.dart';
import 'package:variancedemo/screens/home/home_widgets.dart';
import 'package:variancedemo/utils/widgets.dart';
import 'package:variancedemo/variance_colors.dart';

class WalletHome extends StatefulWidget {
const WalletHome({super.key});

@override
State<WalletHome> createState() => _WalletHomeState();
}

class _WalletHomeState extends State<WalletHome> {
final _formKey = GlobalKey<FormState>();
TextEditingController amountController = TextEditingController();
TextEditingController addressController = TextEditingController();

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: VarianceColors.primary,
body: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const WalletBalance(),
50.verticalSpace,
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton.icon(
onPressed: () {
showModalBottomSheetContent(context);
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xffE1FF01)),
icon: const Icon(Icons.qr_code_2_sharp),
label: const Text(' Receive')),
50.horizontalSpace,
TextButton.icon(
onPressed: () {},
style: TextButton.styleFrom(
backgroundColor: const Color(0xffE1FF01)),
icon: const Icon(
Icons.all_inclusive_outlined,
),
label: const Text('Mint NFT')),
],
),
60.verticalSpace,
AddressBar(
hintText: 'Eth Address',
textEditingController: addressController,
),
18.verticalSpace,
TextFormField(
style: TextStyle(
fontSize: 51.sp,
fontWeight: FontWeight.w600,
color: VarianceColors.secondary),
key: _formKey,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a value';
} else if (int.parse(value) > 100) {
return 'Value should be less than or equal to 100';
}
return null;
},
onChanged: (value) {
if (value.isEmpty) {
return;
}
},
textAlign: TextAlign.center,
controller: amountController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
focusColor: Colors.white,
fillColor: Colors.white,
border: InputBorder.none,
hintText: '0.0',
hintStyle: TextStyle(
fontSize: 51, color: VarianceColors.secondary),
),
cursorColor: VarianceColors.secondary,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'^\.?\d*(?<!\.)\.?\d*'),
)
]),
SizedBox(
height: 58.h,
width: double.infinity,
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
backgroundColor: VarianceColors.white),
onPressed: () {
log(amountController.text);
log(addressController.text);
context.read<WalletProvider>().sendTransaction(
addressController.text, amountController.text);
},
child: const Text('Send')),
),
],
),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,116 +1,16 @@
import 'dart:async';
import 'dart:developer';

import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:variancedemo/providers/wallet_provider.dart';
import 'package:variancedemo/utils/widgets.dart';
import 'package:variancedemo/variance_colors.dart';
import 'dart:ui' as ui;

import 'package:web3_signers/web3_signers.dart';
import 'package:web3dart/web3dart.dart';

class WalletHome extends StatefulWidget {
const WalletHome({super.key});

@override
State<WalletHome> createState() => _WalletHomeState();
}

class _WalletHomeState extends State<WalletHome> {
final _formKey = GlobalKey<FormState>();
TextEditingController amountController = TextEditingController();
TextEditingController addressController = TextEditingController();

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: VarianceColors.primary,
body: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const WalletBalance(),
110.verticalSpace,
AddressBar(
hintText: 'Eth Address',
textEditingController: addressController,
),
18.verticalSpace,
TextFormField(
style: TextStyle(
fontSize: 51.sp,
fontWeight: FontWeight.w600,
color: VarianceColors.secondary),
key: _formKey,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a value';
} else if (int.parse(value) > 100) {
return 'Value should be less than or equal to 100';
}
return null;
},
onChanged: (value) {
if (value.isEmpty) {
return;
}
},
textAlign: TextAlign.center,
controller: amountController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
focusColor: Colors.white,
fillColor: Colors.white,
border: InputBorder.none,
hintText: '0.0',
hintStyle: TextStyle(
fontSize: 51, color: VarianceColors.secondary),
),
cursorColor: VarianceColors.secondary,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(r'^\.?\d*(?<!\.)\.?\d*'),
)
]),
SizedBox(
height: 58.h,
width: double.infinity,
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
backgroundColor: VarianceColors.white),
onPressed: () {
log(amountController.text);
log(addressController.text);
context.read<WalletProvider>().sendTransaction(
addressController.text, amountController.text);
},
child: const Text('Send')),
),
],
),
),
),
floatingActionButton: FloatingActionButton.large(
child: const Icon(Icons.qr_code_2_sharp),
onPressed: () {
showModalBottomSheetContent(context);
},
),
);
}
}

String address = '';

class WalletBalance extends StatefulWidget {
Expand Down Expand Up @@ -273,7 +173,8 @@ showModalBottomSheetContent(BuildContext context) {
const SizedBox(height: 5),
const Spacer(),
SizedBox(
width: 50,
width: 60,
height: 30,
child: TextButton(
onPressed: () {
Clipboard.setData(ClipboardData(
Expand All @@ -282,6 +183,7 @@ showModalBottomSheetContent(BuildContext context) {
},
style: TextButton.styleFrom(
backgroundColor: const Color(0xff32353E),
padding: const EdgeInsets.all(5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
Expand Down
Loading

0 comments on commit c08d89f

Please sign in to comment.