Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
allasca committed Jan 18, 2024
0 parents commit e4787d2
Show file tree
Hide file tree
Showing 75 changed files with 3,726 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

/lib/badgeni/
45 changes: 45 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: android
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: ios
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: linux
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: macos
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: web
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
- platform: windows
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# miggi_multi_spy

A new Flutter project.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
64 changes: 64 additions & 0 deletions lib/controller/main_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:miggi_multi_spy/badgeni/badgeni.dart';

class MainController extends GetxController {
var listRoomController = <TextEditingController>[];
var listResultParticipant = <List<String>>[];

var usernameController = TextEditingController();
var passwordController = TextEditingController();

var isLogin = false.obs;

late BadgeniUs bot;

doSpy() async {
for (var e in listResultParticipant) {
e.clear();
update();
}
bot = BadgeniUs(usernameController.text, passwordController.text);
await Future.delayed(const Duration(seconds: 3));
isLogin.value = bot.isLogin.value;
for (var i = 0; i < 6; i++) {
if (listRoomController[i].text.isEmpty) continue;
Map status = {};
bot.status.clear();
bot.listRoom(listRoomController[i].text);
while (true) {
if (bot.status.isNotEmpty) {
status = bot.status;
break;
}
await Future.delayed(const Duration(milliseconds: 10));
}
List<String> users = [];
if (status['event'] == 'room_list') {
for (var e in status['data']['users']) {
users.add(e['username']);
}
} else {
users.add('Error');
}
listResultParticipant[i] = users;
update();
await Future.delayed(const Duration(seconds: 3));
}
}

createBucket() {
for (var i = 0; i < 6; i++) {
final t = TextEditingController(text: "");
final p = <String>[];
listRoomController.add(t);
listResultParticipant.add(p);
}
}

@override
void onInit() {
createBucket();
super.onInit();
}
}
44 changes: 44 additions & 0 deletions lib/controller/storage_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:miggi_multi_spy/controller/main_controller.dart';
import 'package:miggi_multi_spy/model/storage_model.dart';

class StorageController extends GetxController {
final box = GetStorage("app");
final c = Get.find<MainController>();

save() {
var lRoom = <String>[];
for (TextEditingController e in c.listRoomController) {
lRoom.add(e.text);
}
final d = StorageModel(
username: c.usernameController.text,
password: c.passwordController.text,
listRoom: lRoom,
);
box.write('data', d.toRawJson());
}

load() {
String d = box.read('data') ??
StorageModel(
username: "",
password: "",
listRoom: ["", "", "", "", "", ""],
).toRawJson();
StorageModel j = StorageModel.fromRawJson(d);
c.usernameController.text = j.username;
c.passwordController.text = j.password;
for (var i = 0; i < j.listRoom.length; i++) {
c.listRoomController[i].text = j.listRoom[i];
}
}

@override
void onInit() {
load();
super.onInit();
}
}
23 changes: 23 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:miggi_multi_spy/ui/home_ui.dart';

void main() async {
await GetStorage.init("app");
runApp(const MainApp());
}

class MainApp extends StatelessWidget {
const MainApp({super.key});

@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.dark,
darkTheme: ThemeData.dark(useMaterial3: true),
home: const HomeUI(),
);
}
}
30 changes: 30 additions & 0 deletions lib/model/storage_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'dart:convert';

class StorageModel {
final String username;
final String password;
final List<String> listRoom;

StorageModel({
required this.username,
required this.password,
required this.listRoom,
});

factory StorageModel.fromRawJson(String str) =>
StorageModel.fromJson(json.decode(str));

String toRawJson() => json.encode(toJson());

factory StorageModel.fromJson(Map<String, dynamic> json) => StorageModel(
username: json["username"],
password: json["password"],
listRoom: List<String>.from(json["listRoom"].map((x) => x)),
);

Map<String, dynamic> toJson() => {
"username": username,
"password": password,
"listRoom": List<dynamic>.from(listRoom.map((x) => x)),
};
}
84 changes: 84 additions & 0 deletions lib/ui/home_ui.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:miggi_multi_spy/controller/main_controller.dart';
import 'package:miggi_multi_spy/controller/storage_controller.dart';
import 'package:miggi_multi_spy/ui/widget_spy.dart';

class HomeUI extends StatelessWidget {
const HomeUI({super.key});

@override
Widget build(BuildContext context) {
final c = Get.put(MainController());
final s = Get.put(StorageController());
return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 9),
child: Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Flexible(
child: TextField(
controller: c.usernameController,
onChanged: s.save(),
decoration: const InputDecoration(
label: Text('Username'),
border: OutlineInputBorder(),
),
),
),
const SizedBox(width: 9),
Flexible(
child: TextField(
controller: c.passwordController,
onChanged: s.save(),
obscureText: true,
decoration: const InputDecoration(
label: Text('Password'),
border: OutlineInputBorder(),
),
),
),
const SizedBox(width: 9),
Obx(
() => FilledButton(
onPressed: () {
c.doSpy();
s.save();
},
style: ButtonStyle(
backgroundColor: c.isLogin.value
? MaterialStateProperty.all(Colors.greenAccent)
: MaterialStateProperty.all(Colors.red),
),
child: const Text('SPY ALL'),
),
),
],
),
),
const SizedBox(height: 9),
Expanded(
child: GetBuilder<MainController>(
init: MainController(),
builder: (cc) => Row(
children: List.generate(
6,
(index) => WidgetSpy(
controller: cc.listRoomController[index],
participant: cc.listResultParticipant[index],
),
),
),
),
),
],
),
),
);
}
}
Loading

0 comments on commit e4787d2

Please sign in to comment.