tmp commit
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
803ed68d42
commit
d9755abbc2
@ -17,7 +17,8 @@ import 'package:flutter_hbb/models/server_model.dart';
|
|||||||
import 'package:flutter_hbb/models/user_model.dart';
|
import 'package:flutter_hbb/models/user_model.dart';
|
||||||
import 'package:flutter_hbb/models/state_model.dart';
|
import 'package:flutter_hbb/models/state_model.dart';
|
||||||
import 'package:flutter_hbb/plugin/event.dart';
|
import 'package:flutter_hbb/plugin/event.dart';
|
||||||
import 'package:flutter_hbb/plugin/reloader.dart';
|
import 'package:flutter_hbb/plugin/desc.dart';
|
||||||
|
import 'package:flutter_hbb/plugin/widget.dart';
|
||||||
import 'package:flutter_hbb/common/shared_state.dart';
|
import 'package:flutter_hbb/common/shared_state.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'package:image/image.dart' as img2;
|
import 'package:image/image.dart' as img2;
|
||||||
@ -229,7 +230,7 @@ class FfiModel with ChangeNotifier {
|
|||||||
} else if (name == "fingerprint") {
|
} else if (name == "fingerprint") {
|
||||||
FingerprintState.find(peerId).value = evt['fingerprint'] ?? '';
|
FingerprintState.find(peerId).value = evt['fingerprint'] ?? '';
|
||||||
} else if (name == "plugin_desc") {
|
} else if (name == "plugin_desc") {
|
||||||
handleReloading(evt, peerId);
|
updateDesc(evt);
|
||||||
} else if (name == "plugin_event") {
|
} else if (name == "plugin_event") {
|
||||||
handlePluginEvent(
|
handlePluginEvent(
|
||||||
evt, peerId, (Map<String, dynamic> e) => handleMsgBox(e, peerId));
|
evt, peerId, (Map<String, dynamic> e) => handleMsgBox(e, peerId));
|
||||||
|
1
flutter/lib/plugin/common.dart
Normal file
1
flutter/lib/plugin/common.dart
Normal file
@ -0,0 +1 @@
|
|||||||
|
typedef PluginId = String;
|
@ -38,9 +38,14 @@ class UiType {
|
|||||||
: button = json['t'] == 'Button' ? UiButton.fromJson(json['c']) : null,
|
: button = json['t'] == 'Button' ? UiButton.fromJson(json['c']) : null,
|
||||||
checkbox =
|
checkbox =
|
||||||
json['t'] != 'Checkbox' ? UiCheckbox.fromJson(json['c']) : null;
|
json['t'] != 'Checkbox' ? UiCheckbox.fromJson(json['c']) : null;
|
||||||
|
|
||||||
|
bool get isValid => button != null || checkbox != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Location {
|
class Location {
|
||||||
|
// location key:
|
||||||
|
// host|main|settings|display|others
|
||||||
|
// client|remote|toolbar|display
|
||||||
HashMap<String, UiType> ui;
|
HashMap<String, UiType> ui;
|
||||||
|
|
||||||
Location(this.ui);
|
Location(this.ui);
|
||||||
|
28
flutter/lib/plugin/model.dart
Normal file
28
flutter/lib/plugin/model.dart
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import './common.dart';
|
||||||
|
import './desc.dart';
|
||||||
|
|
||||||
|
// ui location
|
||||||
|
// host|main|settings|display|others
|
||||||
|
// client|remote|toolbar|display
|
||||||
|
|
||||||
|
final Map<PluginId, Map<String, LocationModel>> locationModels = {};
|
||||||
|
|
||||||
|
class LocationModel with ChangeNotifier {
|
||||||
|
final List<UiType> uiList = [];
|
||||||
|
|
||||||
|
void add(UiType ui) {
|
||||||
|
uiList.add(ui);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void addLocation(PluginId id, String location, UiType ui) {
|
||||||
|
if (!locationModels.containsKey(id)) {
|
||||||
|
locationModels[id] = {};
|
||||||
|
}
|
||||||
|
if (!locationModels[id]!.containsKey(location)) {
|
||||||
|
locationModels[id]![location] = LocationModel();
|
||||||
|
}
|
||||||
|
locationModels[id]![location]!.add(ui);
|
||||||
|
}
|
@ -1,29 +0,0 @@
|
|||||||
void handleReloading(Map<String, dynamic> evt, String peer) {
|
|
||||||
// location
|
|
||||||
// host|main|settings|display|others
|
|
||||||
// client|remote|toolbar|display
|
|
||||||
//
|
|
||||||
// ui
|
|
||||||
// {
|
|
||||||
// "t": "Button",
|
|
||||||
// "c": {
|
|
||||||
// "key": "key",
|
|
||||||
// "text": "text",
|
|
||||||
// "icon": "icon",
|
|
||||||
// "tooltip": "tooltip",
|
|
||||||
// "action": "action"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// {
|
|
||||||
// "t": "Checkbox",
|
|
||||||
// "c": {
|
|
||||||
// "key": "key",
|
|
||||||
// "text": "text",
|
|
||||||
// "tooltip": "tooltip",
|
|
||||||
// "action": "action"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import './desc.dart';
|
||||||
|
import './model.dart';
|
||||||
|
|
||||||
final Map<String, PluginWidget> pluginWidgets = {};
|
final Map<String, PluginWidget> pluginWidgets = {};
|
||||||
|
|
||||||
@ -14,4 +16,32 @@ class PluginWidget {
|
|||||||
required this.location,
|
required this.location,
|
||||||
required this.widget,
|
required this.widget,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// static Widget createButton(UiButton btn) {}
|
||||||
|
|
||||||
|
// static Widget createCheckbox(UiCheckbox chk) {}
|
||||||
|
|
||||||
|
// // ui location
|
||||||
|
// // host|main|settings|display|others
|
||||||
|
// // client|remote|toolbar|display
|
||||||
|
// static Widget? create(String id, String locatin, UiType ui) {
|
||||||
|
// if (ui.button != null) {
|
||||||
|
// return createButton(ui.button!);
|
||||||
|
// } else if (ui.checkbox != null) {
|
||||||
|
// return createCheckbox(ui.checkbox!);
|
||||||
|
// } else {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleReloading(Map<String, dynamic> evt, String peer) {
|
||||||
|
if (evt['id'] == null || evt['location'] == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final ui = UiType.fromJson(evt);
|
||||||
|
if (!ui.isValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addLocation(evt['id']!, evt['location']!, ui);
|
||||||
}
|
}
|
||||||
|
27
flutter/lib/plugin/widgets/remote/toolbar/display.dart
Normal file
27
flutter/lib/plugin/widgets/remote/toolbar/display.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../model.dart';
|
||||||
|
|
||||||
|
class Display extends StatelessWidget {
|
||||||
|
final String peerId;
|
||||||
|
final LocationModel locationModel;
|
||||||
|
|
||||||
|
Display({
|
||||||
|
Key? key,
|
||||||
|
required this.peerId,
|
||||||
|
required this.locationModel,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ChangeNotifierProvider.value(
|
||||||
|
value: locationModel,
|
||||||
|
child: Consumer<LocationModel>(builder: (context, model, child) {
|
||||||
|
return Column(
|
||||||
|
children: [],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user