70 lines
1.9 KiB
Dart
70 lines
1.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:libacflutter/Constants.dart';
|
|
import 'package:libacflutter/Prompt.dart';
|
|
|
|
void main() {
|
|
test("Test the input prompt", () async {
|
|
runApp(WidgetTester(route: "/testprompt"));
|
|
});
|
|
}
|
|
|
|
class WidgetTester extends StatelessWidget {
|
|
String route;
|
|
|
|
WidgetTester({required this.route});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
theme: ThemeData.dark(),
|
|
routes: {"/testprompt": (context) => TestPrompt()},
|
|
home: TestPrompt(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class TestPrompt extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return TestPromptState();
|
|
}
|
|
}
|
|
|
|
class TestPromptState extends State<TestPrompt> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Input Prompt Test"),
|
|
backgroundColor: LibACFlutterConstants.TITLEBAR_COLOR,
|
|
),
|
|
body: Column(
|
|
children: [
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
var reply = await showAdaptiveDialog(
|
|
context: context,
|
|
builder: (buildx) {
|
|
return InputPrompt(
|
|
title: "Test",
|
|
prompt: "Enter a value",
|
|
currentValue: "",
|
|
type: InputPromptType.Text,
|
|
);
|
|
});
|
|
|
|
// Show a alert dialog with the reply content
|
|
showAdaptiveDialog(
|
|
context: context,
|
|
builder: (buildx) {
|
|
return Alert(title: "Test Result", body: reply);
|
|
});
|
|
},
|
|
child: Text("Show prompt"))
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|