|
|
@ -1,5 +1,6 @@
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:signature/signature.dart';
|
|
|
|
import 'package:signature/signature.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
@ -20,6 +21,8 @@ class SignNameBoard extends StatefulWidget {
|
|
|
|
return FadeTransition(
|
|
|
|
return FadeTransition(
|
|
|
|
opacity: animation,
|
|
|
|
opacity: animation,
|
|
|
|
child: SignNameBoard(
|
|
|
|
child: SignNameBoard(
|
|
|
|
|
|
|
|
width: 600.w,
|
|
|
|
|
|
|
|
height: double.infinity,
|
|
|
|
signatureController: _signatureController,
|
|
|
|
signatureController: _signatureController,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -29,8 +32,14 @@ class SignNameBoard extends StatefulWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final SignatureController signatureController;
|
|
|
|
final SignatureController signatureController;
|
|
|
|
|
|
|
|
final bool forceToHorizontal;
|
|
|
|
SignNameBoard({Key? key, required this.signatureController})
|
|
|
|
final double width;
|
|
|
|
|
|
|
|
final double height;
|
|
|
|
|
|
|
|
SignNameBoard(
|
|
|
|
|
|
|
|
{Key? key,
|
|
|
|
|
|
|
|
required this.signatureController,
|
|
|
|
|
|
|
|
this.forceToHorizontal = true,
|
|
|
|
|
|
|
|
required this.width, required this.height})
|
|
|
|
: super(key: key);
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -38,9 +47,26 @@ class SignNameBoard extends StatefulWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _SignNameBoardState extends State<SignNameBoard> {
|
|
|
|
class _SignNameBoardState extends State<SignNameBoard> {
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
if (widget.forceToHorizontal) {
|
|
|
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
|
|
|
|
DeviceOrientation.landscapeLeft,
|
|
|
|
|
|
|
|
DeviceOrientation.landscapeRight,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
void dispose() {
|
|
|
|
widget.signatureController.dispose();
|
|
|
|
widget.signatureController.dispose();
|
|
|
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
|
|
|
|
DeviceOrientation.portraitDown,
|
|
|
|
|
|
|
|
]);
|
|
|
|
super.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -49,33 +75,51 @@ class _SignNameBoardState extends State<SignNameBoard> {
|
|
|
|
Signature signature = Signature(
|
|
|
|
Signature signature = Signature(
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
controller: widget.signatureController,
|
|
|
|
controller: widget.signatureController,
|
|
|
|
width: double.infinity,
|
|
|
|
width: widget.width,
|
|
|
|
height: 1000.w,
|
|
|
|
height:widget.height,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
IconButton finishButton = IconButton(
|
|
|
|
IconButton finishButton = IconButton(
|
|
|
|
|
|
|
|
iconSize: 50.w,
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
Get.back(result: widget.signatureController.toPngBytes());
|
|
|
|
Get.back(result: widget.signatureController.toPngBytes());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
icon: Icon(
|
|
|
|
icon: Icon(
|
|
|
|
CupertinoIcons.checkmark_alt_circle,
|
|
|
|
CupertinoIcons.checkmark_alt_circle,
|
|
|
|
size: 100.w,
|
|
|
|
color: Colors.blue,
|
|
|
|
|
|
|
|
// size: 100.w,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
IconButton clearButton = IconButton(
|
|
|
|
IconButton clearButton = IconButton(
|
|
|
|
|
|
|
|
iconSize: 50.w,
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
widget.signatureController.clear();
|
|
|
|
widget.signatureController.clear();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
icon: Icon(
|
|
|
|
icon: Icon(
|
|
|
|
CupertinoIcons.clear_circled,
|
|
|
|
CupertinoIcons.clear_circled,
|
|
|
|
size: 100.w,
|
|
|
|
color: Colors.red,
|
|
|
|
|
|
|
|
// size: 100.w,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return Center(
|
|
|
|
return Scaffold(
|
|
|
|
|
|
|
|
body: widget.forceToHorizontal
|
|
|
|
|
|
|
|
? Row(
|
|
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
signature,
|
|
|
|
|
|
|
|
Material(
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
finishButton.expand(),
|
|
|
|
|
|
|
|
clearButton.expand(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
).expand()
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
signature,
|
|
|
|
signature,
|
|
|
|
200.w.heightBox,
|
|
|
|
|
|
|
|
Material(
|
|
|
|
Material(
|
|
|
|
child: Row(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
@ -83,7 +127,7 @@ class _SignNameBoardState extends State<SignNameBoard> {
|
|
|
|
clearButton.expand(),
|
|
|
|
clearButton.expand(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).expand(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|