Skip to content

Commit 2376272

Browse files
committed
feat: integrated surrealdb.wasm 1.0.0-beta.14 and surrealdb_js 1.0.0-beta.14+3
1 parent 8b3d747 commit 2376272

25 files changed

+866
-902
lines changed

ci-integration-test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
surreal start memory --allow-all --auth --user root --pass root &
12
flutter drive --driver=test_driver/integration_test.dart --target integration_test/all_tests.dart -d web-server --release --browser-name=chrome
3+
killall surreal
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Aijin Yuan (a.k.a. Vince Yuan)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
library flutter_console_widget;
2+
3+
export 'package:flutter_console_widget/flutter_console_controller.dart';
4+
5+
import 'package:flutter/material.dart';
6+
import 'package:flutter_console_widget/flutter_console_controller.dart';
7+
import 'package:flutter_console_widget/selectable_colored_text.dart';
8+
9+
class FlutterConsole extends StatelessWidget {
10+
const FlutterConsole({
11+
this.consoleBackground = Colors.black,
12+
this.consoleTextColor = Colors.white,
13+
this.consoleSelectedTextBackgroundColor = Colors.white,
14+
this.consoleSelectedTextColor = Colors.black,
15+
required this.controller,
16+
required this.height,
17+
this.inputBackground = const Color(0xff333333),
18+
this.inputTextColor = Colors.white,
19+
Key? key,
20+
this.scrollColor = Colors.grey,
21+
required this.width,
22+
}) : super(key: key);
23+
24+
final Color consoleBackground;
25+
final Color consoleTextColor;
26+
final Color consoleSelectedTextBackgroundColor;
27+
final Color consoleSelectedTextColor;
28+
final FlutterConsoleController controller;
29+
final double height;
30+
final Color inputBackground;
31+
final Color inputTextColor;
32+
final Color scrollColor;
33+
final double width;
34+
35+
@override
36+
Widget build(BuildContext context) {
37+
return ValueListenableBuilder<FlutterConsoleData>(
38+
valueListenable: controller,
39+
builder: (context, consoleData, _) {
40+
return !consoleData.show
41+
? const SizedBox.shrink()
42+
: Container(
43+
color: consoleBackground,
44+
width: width,
45+
height: height,
46+
child: Column(
47+
mainAxisSize: MainAxisSize.min,
48+
crossAxisAlignment: CrossAxisAlignment.start,
49+
children: [
50+
Expanded(
51+
child: SizedBox(
52+
width: width,
53+
child: Theme(
54+
data: ThemeData.light().copyWith(
55+
scrollbarTheme:
56+
const ScrollbarThemeData().copyWith(
57+
thumbColor: WidgetStateProperty.all(scrollColor),
58+
)),
59+
child: Scrollbar(
60+
controller: controller.scrollController,
61+
child: SingleChildScrollView(
62+
physics: const BouncingScrollPhysics(),
63+
controller: controller.scrollController,
64+
child: Padding(
65+
padding: const EdgeInsets.all(8.0),
66+
child: SelectableColoredText(
67+
consoleData.consoleContent,
68+
style: TextStyle(
69+
color: consoleTextColor,
70+
),
71+
selectedTextColor: consoleSelectedTextColor,
72+
selectedTextBackgroundColor:
73+
consoleSelectedTextBackgroundColor,
74+
),
75+
),
76+
),
77+
),
78+
),
79+
),
80+
),
81+
Container(
82+
color: inputBackground,
83+
padding: const EdgeInsets.only(bottom: 5.0),
84+
child: Row(
85+
children: [
86+
const SizedBox(
87+
width: 10,
88+
),
89+
Icon(
90+
Icons.arrow_forward_ios,
91+
color: inputTextColor,
92+
size: 20,
93+
),
94+
Flexible(
95+
child: TextField(
96+
autofocus: true,
97+
keyboardType: consoleData.keyboardType,
98+
controller: controller.inputController,
99+
focusNode: controller.focusNode,
100+
cursorColor: inputTextColor,
101+
style: TextStyle(color: inputTextColor),
102+
decoration: InputDecoration(
103+
filled: true,
104+
fillColor: inputBackground,
105+
border: InputBorder.none,
106+
contentPadding: const EdgeInsets.only(
107+
right: 10,
108+
left: 5,
109+
),
110+
),
111+
onSubmitted: (value) {
112+
if (!controller.completer.isCompleted) {
113+
controller.completer.complete(
114+
value,
115+
);
116+
}
117+
},
118+
),
119+
),
120+
ElevatedButton(
121+
style: ElevatedButton.styleFrom(
122+
backgroundColor: consoleBackground,
123+
),
124+
onPressed: () {
125+
if (!controller.completer.isCompleted) {
126+
controller.completer.complete(
127+
controller.inputController.text,
128+
);
129+
}
130+
},
131+
child: const Icon(Icons.done),
132+
),
133+
const SizedBox(
134+
width: 10,
135+
),
136+
],
137+
),
138+
)
139+
],
140+
),
141+
);
142+
});
143+
}
144+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter/material.dart';
4+
5+
class FlutterConsoleController extends ValueNotifier<FlutterConsoleData> {
6+
FlutterConsoleController({
7+
String consoleContent = '',
8+
}) : super(
9+
FlutterConsoleData(
10+
keyboardType: TextInputType.none,
11+
consoleContent: consoleContent,
12+
),
13+
);
14+
15+
final FocusNode focusNode = FocusNode();
16+
final TextEditingController inputController = TextEditingController();
17+
final ScrollController scrollController = ScrollController();
18+
Completer<String> completer = Completer();
19+
20+
void show() {
21+
value = value.copyWith(
22+
show: true,
23+
);
24+
}
25+
26+
void hide() {
27+
value = value.copyWith(
28+
show: false,
29+
);
30+
}
31+
32+
void print({required String message, required bool endline}) {
33+
value = value.copyWith(
34+
consoleContent: '${value.consoleContent}$message${endline ? '\n' : ''}',
35+
);
36+
37+
Future.delayed(
38+
const Duration(
39+
milliseconds: 100,
40+
),
41+
).then((value) {
42+
scrollController.animateTo(
43+
scrollController.position.maxScrollExtent,
44+
duration: const Duration(milliseconds: 300),
45+
curve: Curves.easeOut,
46+
);
47+
});
48+
}
49+
50+
Future<String> scan({TextInputType? keyboardType}) async {
51+
completer = Completer();
52+
value = value.copyWith(
53+
keyboardType: keyboardType,
54+
);
55+
final readedValue = await completer.future;
56+
inputController.clear();
57+
return readedValue;
58+
}
59+
60+
void clear() {
61+
value = value.copyWith(consoleContent: '');
62+
}
63+
}
64+
65+
class FlutterConsoleData {
66+
FlutterConsoleData({
67+
this.keyboardType = TextInputType.none,
68+
this.consoleContent = '',
69+
this.show = true,
70+
});
71+
72+
final TextInputType keyboardType;
73+
final String consoleContent;
74+
final bool show;
75+
76+
FlutterConsoleData copyWith({
77+
TextInputType? keyboardType,
78+
String? consoleContent,
79+
bool? show,
80+
}) =>
81+
FlutterConsoleData(
82+
keyboardType: keyboardType ?? this.keyboardType,
83+
consoleContent: consoleContent ?? this.consoleContent,
84+
show: show ?? this.show,
85+
);
86+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import 'package:flutter/material.dart';
2+
import 'dart:math';
3+
4+
// REF: https://stackoverflow.com/questions/68604853/set-the-color-of-selected-text
5+
class SelectableColoredText extends StatefulWidget {
6+
final String text;
7+
final TextStyle? style;
8+
final Color selectedTextColor;
9+
final Color selectedTextBackgroundColor;
10+
11+
const SelectableColoredText(
12+
this.text, {
13+
Key? key,
14+
this.style,
15+
required this.selectedTextColor,
16+
required this.selectedTextBackgroundColor,
17+
}) : super(key: key);
18+
19+
@override
20+
// ignore: library_private_types_in_public_api
21+
_SelectableColoredTextState createState() => _SelectableColoredTextState();
22+
}
23+
24+
class _SelectableColoredTextState extends State<SelectableColoredText> {
25+
int? _start;
26+
int? _end;
27+
28+
@override
29+
Widget build(BuildContext context) {
30+
final int start = _start ?? widget.text.length;
31+
final int end = _end ?? widget.text.length;
32+
return SelectableText.rich(
33+
TextSpan(
34+
style: widget.style ?? Theme.of(context).textTheme.bodyMedium,
35+
children: [
36+
// Text before the selection
37+
TextSpan(text: widget.text.substring(0, start)),
38+
// Selected text
39+
TextSpan(
40+
text: widget.text.substring(start, end),
41+
style: TextStyle(
42+
color: widget.selectedTextColor,
43+
backgroundColor: widget.selectedTextBackgroundColor,
44+
),
45+
),
46+
// Text after the selection
47+
TextSpan(text: widget.text.substring(end, widget.text.length)),
48+
],
49+
),
50+
// Update the start and end positions of the selection
51+
onSelectionChanged: (selection, _) {
52+
final int newStart = min(selection.baseOffset, selection.extentOffset);
53+
final int newEnd = max(selection.baseOffset, selection.extentOffset);
54+
if (_start == newStart && _end == newEnd) return;
55+
setState(() {
56+
_start = newStart;
57+
_end = newEnd;
58+
});
59+
},
60+
);
61+
}
62+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: flutter_console_widget
2+
description: FlutterConsole allows you to print and scan just like in a console terminal
3+
version: 0.0.3
4+
repository: https://github.com/semakers/flutter_console
5+
6+
environment:
7+
sdk: '>=2.19.6 <3.0.0'
8+
flutter: ">=1.17.0"
9+
10+
dependencies:
11+
flutter:
12+
sdk: flutter
13+
14+
dev_dependencies:
15+
flutter_test:
16+
sdk: flutter
17+
flutter_lints: ^2.0.0
18+
19+
# For information on the generic Dart part of this file, see the
20+
# following page: https://dart.dev/tools/pub/pubspec
21+
22+
# The following section is specific to Flutter packages.
23+
flutter:
24+
25+
# To add assets to your package, add an assets section, like this:
26+
# assets:
27+
# - images/a_dot_burr.jpeg
28+
# - images/a_dot_ham.jpeg
29+
#
30+
# For details regarding assets in packages, see
31+
# https://flutter.dev/assets-and-images/#from-packages
32+
#
33+
# An image asset can refer to one or more resolution-specific "variants", see
34+
# https://flutter.dev/assets-and-images/#resolution-aware
35+
36+
# To add custom fonts to your package, add a fonts section here,
37+
# in this "flutter" section. Each entry in this list should have a
38+
# "family" key with the font family name, and a "fonts" key with a
39+
# list giving the asset and other descriptors for the font. For
40+
# example:
41+
# fonts:
42+
# - family: Schyler
43+
# fonts:
44+
# - asset: fonts/Schyler-Regular.ttf
45+
# - asset: fonts/Schyler-Italic.ttf
46+
# style: italic
47+
# - family: Trajan Pro
48+
# fonts:
49+
# - asset: fonts/TrajanPro.ttf
50+
# - asset: fonts/TrajanPro_Bold.ttf
51+
# weight: 700
52+
#
53+
# For details regarding fonts in packages, see
54+
# https://flutter.dev/custom-fonts/#from-packages

0 commit comments

Comments
 (0)