Skip to content

Commit

Permalink
Commit some code
Browse files Browse the repository at this point in the history
  • Loading branch information
mengyanshou committed Aug 29, 2023
1 parent bb05914 commit c993cc5
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 153 deletions.
6 changes: 0 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@
"type": "dart",
"deviceId": "windows"
},
{
"name": "小米平板5 12.4",
"request": "launch",
"type": "dart",
"deviceId": "22081281AC"
},
{
"name": "小米13",
"request": "launch",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.5.4
- 优化多个UI界面对夜间模式的适配:历史记录、终端界面

## 1.5.3
- 修复启动卡死、崩溃等问题
- 修复关于页面资源图片加载失败,官网跳转失败的问题
Expand Down
66 changes: 36 additions & 30 deletions lib/adbkit_entrypoint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ADBToolEntryPoint extends StatefulWidget {

class _ADBToolEntryPointState extends State<ADBToolEntryPoint> with WindowListener {
ConfigController configController = Get.put(ConfigController());
TabController controller = Get.put(TabController());
@override
void onWindowFocus() {
// Make sure to call once.
Expand Down Expand Up @@ -66,6 +67,7 @@ class _ADBToolEntryPointState extends State<ADBToolEntryPoint> with WindowListen
}
await initSetting();
configController.initConfig();
setState(() {});
await Global.instance!.initGlobal();
Global.instance!.hasSafeArea = widget.hasSafeArea;
Global.instance!.showQRCode = widget.showQRCode;
Expand All @@ -75,11 +77,8 @@ class _ADBToolEntryPointState extends State<ADBToolEntryPoint> with WindowListen
isInit = true;
}

//Create an instance of ScreenshotController

@override
Widget build(BuildContext context) {
TabController controller = TabController();
void initState() {
controller.setInitPage(
PageEntity(
title: 'ADB KIT',
Expand Down Expand Up @@ -127,35 +126,42 @@ class _ADBToolEntryPointState extends State<ADBToolEntryPoint> with WindowListen
),
),
);
return GetBuilder<TabController>(
init: controller,
super.initState();
}

//Create an instance of ScreenshotController

@override
Widget build(BuildContext context) {
return Global().rootWidget ??= GetBuilder<TabController>(
autoRemove: false,
builder: (controller) {
return Scaffold(
backgroundColor: const Color(0xfff3f4f9),
body: Column(
children: [
TopTab(
onChanged: (int index) {
controller.changePage(index);
Log.d(index);
},
children: [
for (PageEntity page in controller.pages)
Text(
page.title,
style: TextStyle(
fontSize: 12.w,
fontWeight: FontWeight.bold,
height: 1,
),
return Column(
children: [
TopTab(
onChanged: (int index) {
controller.changePage(index);
Log.d(index);
},
children: [
for (PageEntity page in controller.pages)
Text(
page.title,
style: TextStyle(
fontSize: 12.w,
fontWeight: FontWeight.bold,
height: 1,
),
],
),
Expanded(
),
],
),
Builder(builder: (context) {
print('controller.pageindex -> ${controller.pageindex} controller.pages.length -> ${controller.pages.length}');
return Expanded(
child: controller.pages[controller.pageindex].page,
),
],
),
);
}),
],
);
},
);
Expand Down
27 changes: 1 addition & 26 deletions lib/app/modules/drawer/tablet_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,7 @@ class _TabletDrawerState extends State<TabletDrawer> {
RippleRoute(
GetBuilder<ConfigController>(
builder: (context) {
return Theme(
data: context.theme!,
child: Stack(
children: [
GetBuilder<ConfigController>(builder: (_) {
if (config.backgroundStyle == BackgroundStyle.normal) {
return Container(
color: theme.colorScheme.background,
);
}
if (config.backgroundStyle == BackgroundStyle.image) {
return SizedBox(
height: double.infinity,
child: Image.asset(
'assets/b.png',
fit: BoxFit.cover,
),
);
} else {
return const SizedBox();
}
}),
const AdbTool(),
],
),
);
return Theme(data: context.theme!, child: Global().rootWidget!);
},
),
RouteConfig.fromContext(context),
Expand Down
11 changes: 6 additions & 5 deletions lib/app/modules/history/history_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class HistoryPage extends GetView<HistoryController> {
onDismissed: (direction) {
ctl.removeHis(i);
},
child: buildItem(adbEntity),
child: buildItem(adbEntity, context),
);
},
),
Expand Down Expand Up @@ -93,7 +93,8 @@ class HistoryPage extends GetView<HistoryController> {
);
}

InkWell buildItem(Data adbEntity) {
InkWell buildItem(Data adbEntity, BuildContext context) {
print('Theme.of(context).textTheme.bodyMedium!.color -> ${Theme.of(context).textTheme.bodyMedium!.color}');
return InkWell(
onTap: () async {
AdbResult result;
Expand Down Expand Up @@ -144,7 +145,7 @@ class HistoryPage extends GetView<HistoryController> {
adbEntity.port,
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white.withOpacity(0.8),
color: Theme.of(context).textTheme.bodyMedium!.color!.withOpacity(0.8),
fontSize: 10.w,
),
),
Expand All @@ -165,7 +166,7 @@ class HistoryPage extends GetView<HistoryController> {
DateTime.parse(adbEntity.connectTime).getTimeString(),
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white.withOpacity(0.8),
color: Theme.of(context).textTheme.bodyMedium!.color!.withOpacity(0.8),
fontSize: 10.w,
),
),
Expand All @@ -177,7 +178,7 @@ class HistoryPage extends GetView<HistoryController> {
Text(
adbEntity.address,
style: TextStyle(
color: Theme.of(Get.context!).colorScheme.onSurface.withOpacity(0.8),
color: Theme.of(context).textTheme.bodyMedium!.color!.withOpacity(0.8),
),
),
],
Expand Down
1 change: 1 addition & 0 deletions lib/app/modules/home/bindings/home_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HomeBinding extends Bindings {
if (RuntimeEnvir.packageName == Config.packageName) {
Get.put(DevicesController());
}
Get.put(TabController());
Get.put(HistoryController());
Get.put(ConfigController());
}
Expand Down
5 changes: 3 additions & 2 deletions lib/app/modules/terminal_page/suggestion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class _HomeState extends State<Home> {
String jsonStr = await compute(utf8.decode, decompressedBytes);
Log.i('utf8.decode time: ${stopwatch.elapsedMilliseconds}ms');

final specs = await json.decode(jsonStr) as Map<String, dynamic>;
final specs = await compute(json.decode, jsonStr);
Log.i('json.decode: ${stopwatch.elapsedMilliseconds}ms');
engine.load(specs);
isLoad = true;
Expand Down Expand Up @@ -273,6 +273,7 @@ class _HomeState extends State<Home> {

@override
Widget build(BuildContext context) {
bool isDark = Theme.of(context).brightness == Brightness.dark;
return Scaffold(
backgroundColor: Colors.transparent,
body: SuggestionPortal(
Expand Down Expand Up @@ -318,7 +319,7 @@ class _HomeState extends State<Home> {

return KeyEventResult.ignored;
},
theme: GetPlatform.isAndroid ? android : theme,
theme: (isDark ? TerminalThemes.whiteOnBlack : theme),
),
),
);
Expand Down
58 changes: 20 additions & 38 deletions lib/app/routes/ripple_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ class RouteConfig {
if (offset.dy > size.height / 2) {
circleRadius = sqrt(pow(offset.dx, 2) + pow(offset.dy, 2)).toDouble();
} else {
circleRadius = sqrt(pow(offset.dx, 2) + pow(size.height - offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(offset.dx, 2) + pow(size.height - offset.dy, 2)).toDouble();
}
}
if (offset.dx <= size.width / 2) {
if (offset.dy > size.height / 2) {
circleRadius =
sqrt(pow(size.width - offset.dx, 2) + pow(offset.dy, 2)).toDouble();
circleRadius = sqrt(pow(size.width - offset.dx, 2) + pow(offset.dy, 2)).toDouble();
} else {
circleRadius = sqrt(pow(size.width - offset.dx, 2) +
pow(size.height - offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(size.width - offset.dx, 2) + pow(size.height - offset.dy, 2)).toDouble();
}
}
}
Expand All @@ -31,18 +27,14 @@ class RouteConfig {
if (offset.dy > size.height / 2) {
circleRadius = sqrt(pow(offset.dx, 2) + pow(offset.dy, 2)).toDouble();
} else {
circleRadius = sqrt(pow(offset.dx, 2) + pow(size.height - offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(offset.dx, 2) + pow(size.height - offset.dy, 2)).toDouble();
}
}
if (offset.dx <= size.width / 2) {
if (offset.dy > size.height / 2) {
circleRadius =
sqrt(pow(size.width - offset.dx, 2) + pow(offset.dy, 2)).toDouble();
circleRadius = sqrt(pow(size.width - offset.dx, 2) + pow(offset.dy, 2)).toDouble();
} else {
circleRadius = sqrt(pow(size.width - offset.dx, 2) +
pow(size.height - offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(size.width - offset.dx, 2) + pow(size.height - offset.dy, 2)).toDouble();
}
}
}
Expand All @@ -54,22 +46,14 @@ class RouteConfig {
if (offset.dy > MediaQuery.of(context).size.height / 2) {
circleRadius = sqrt(pow(offset.dx, 2) + pow(offset.dy, 2)).toDouble();
} else {
circleRadius = sqrt(pow(offset.dx, 2) +
pow(MediaQuery.of(context).size.height - offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(offset.dx, 2) + pow(MediaQuery.of(context).size.height - offset.dy, 2)).toDouble();
}
}
if (offset.dx <= MediaQuery.of(context).size.width / 2) {
if (offset.dy > MediaQuery.of(context).size.height / 2) {
circleRadius = sqrt(
pow(MediaQuery.of(context).size.width - offset.dx, 2) +
pow(offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(MediaQuery.of(context).size.width - offset.dx, 2) + pow(offset.dy, 2)).toDouble();
} else {
circleRadius = sqrt(
pow(MediaQuery.of(context).size.width - offset.dx, 2) +
pow(MediaQuery.of(context).size.height - offset.dy, 2))
.toDouble();
circleRadius = sqrt(pow(MediaQuery.of(context).size.width - offset.dx, 2) + pow(MediaQuery.of(context).size.height - offset.dy, 2)).toDouble();
}
}
}
Expand All @@ -82,7 +66,7 @@ class RippleRoute extends PageRouteBuilder<void> {
RippleRoute(this.widget, this.routeConfig)
: super(
// 设置过度时间
transitionDuration: const Duration(milliseconds: 600),
transitionDuration: const Duration(milliseconds: 800),

// 构造器
pageBuilder: (
Expand All @@ -100,27 +84,25 @@ class RippleRoute extends PageRouteBuilder<void> {
Animation<double> _,
Widget child,
) {
Animation curve = CurvedAnimation(
curve: Curves.easeInToLinear, parent: animation);
// easeInBack
// easeInOutCubicEmphasized配合长时间的Duration
Animation curve = CurvedAnimation(curve: Curves.easeInBack, parent: animation);
print('curve.value:${curve.value}');
return Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
top: routeConfig.offset.dy -
routeConfig.circleRadius * curve.value,
left: routeConfig.offset.dx -
routeConfig.circleRadius * curve.value,
top: routeConfig.offset.dy - (routeConfig.circleRadius * curve.value).abs(),
left: routeConfig.offset.dx - (routeConfig.circleRadius * curve.value).abs(),
child: SizedBox(
height: routeConfig.circleRadius * 2 * curve.value,
width: routeConfig.circleRadius * 2 * curve.value,
height: (routeConfig.circleRadius * 2 * curve.value).abs(),
width: (routeConfig.circleRadius * 2 * curve.value).abs(),
child: ClipOval(
child: Stack(
children: <Widget>[
Positioned(
top: routeConfig.circleRadius * curve.value -
routeConfig.offset.dy,
left: routeConfig.circleRadius * curve.value -
routeConfig.offset.dx,
top: (routeConfig.circleRadius * curve.value).abs() - routeConfig.offset.dy,
left: (routeConfig.circleRadius * curve.value).abs() - routeConfig.offset.dx,
child: Align(
alignment: Alignment.center,
child: SizedBox(
Expand Down
2 changes: 2 additions & 0 deletions lib/global/instance/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ class Global {
await installAdbToEnvir();
await initApi('ADB KIT', Config.versionName);
}

Widget? rootWidget;
}

class Print implements Printable {
Expand Down
2 changes: 1 addition & 1 deletion lib/global/widget/xterm_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TerminalTheme android = const TerminalTheme(

TerminalTheme theme = const TerminalTheme(
cursor: Color(0XAAAEAFAD),
selection: Color(0XFFFFFF40),
selection: Color(0XAAAEAFAD),
foreground: Color(0XFF000000),
background: Color(0XFF000000),
black: Color(0XFF000000),
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Future<void> runADBClient({Color? primary}) async {
Get.config(
enableLog: false,
logWriterCallback: (text, {bool? isError}) {
// Log.d(text, tag: 'GetX');
Log.d(text, tag: 'GetX');
},
);
// set primary color
Expand Down
Loading

0 comments on commit c993cc5

Please sign in to comment.