You've already forked flutter-rp-example
First commit
This commit is contained in:
69
lib/widgets/components/reflex_signature.dart
Normal file
69
lib/widgets/components/reflex_signature.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_signaturepad/signaturepad.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import '../../globals.dart';
|
||||
|
||||
class ReflexSignature extends StatefulWidget {
|
||||
final GlobalKey<SfSignaturePadState> signaturePadKey;
|
||||
|
||||
ReflexSignature({Key? key, required this.signaturePadKey}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ReflexSignatureState createState() => _ReflexSignatureState();
|
||||
}
|
||||
|
||||
class _ReflexSignatureState extends State<ReflexSignature> {
|
||||
bool isInputFocused = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InputDecorator(
|
||||
isFocused: isInputFocused,
|
||||
decoration: InputDecoration(
|
||||
focusColor: Globals.RP_PRIMARY_COLOR,
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
const BorderSide(color: Globals.RP_PRIMARY_COLOR, width: 2.0),
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
const BorderSide(color: Globals.RP_LIGHT_COLOR, width: 1.0),
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
labelText: AppLocalizations.of(context)!.signature,
|
||||
),
|
||||
child: Stack(children: [
|
||||
SfSignaturePad(
|
||||
key: widget.signaturePadKey,
|
||||
minimumStrokeWidth: 2,
|
||||
maximumStrokeWidth: 2,
|
||||
strokeColor: Colors.black,
|
||||
onDrawStart: () {
|
||||
setState(() {
|
||||
isInputFocused = true;
|
||||
});
|
||||
return false;
|
||||
},
|
||||
onDrawEnd: () {
|
||||
setState(() {
|
||||
isInputFocused = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Globals.RP_BG_DARK_COLOR,
|
||||
child: IconButton(
|
||||
color: Colors.black,
|
||||
onPressed: () {
|
||||
widget.signaturePadKey.currentState!.clear();
|
||||
},
|
||||
icon: const Icon(Icons.clear))),
|
||||
)
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user