Skip to content

Commit

Permalink
🚀 ✨ Optimized View Switching, Adding Support for #12, #1!
Browse files Browse the repository at this point in the history
  • Loading branch information
omegaui committed Mar 11, 2023
1 parent 3bf10d8 commit 22a0afd
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 45 deletions.
66 changes: 33 additions & 33 deletions lib/core/client/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,39 @@ void main() {
File("/home/omegaui/Downloads/icons8-package-94.png")
.readAsBytesSync()))
.connect("127.0.0.1", 8080, (p0) {});
Client(
id: "zeno",
description: "Just Another User",
code: "code",
avatar: base64UrlEncode(
File("/home/omegaui/Downloads/icons8-kawaii-shellfish-96.png")
.readAsBytesSync()))
.connect("127.0.0.1", 8080, (p0) {});
Client(
id: "_mike",
description: "Just Another User",
code: "code",
avatar: base64UrlEncode(
File("/home/omegaui/Downloads/icons8-markdown-100.png")
.readAsBytesSync()))
.connect("127.0.0.1", 8080, (p0) {});
Client(
id: "pluto",
description: "Just Another User",
code: "code",
avatar: base64UrlEncode(
File("/home/omegaui/Downloads/icons8-kawaii-shellfish-96.png")
.readAsBytesSync()))
.connect("127.0.0.1", 8080, (p0) {});

Client(
id: "john",
description: "Just Another User",
code: "code",
avatar: base64UrlEncode(
File("/home/omegaui/Downloads/icons8-kawaii-shellfish-96.png")
.readAsBytesSync()))
.connect("127.0.0.1", 8080, (p0) {});
// Client(
// id: "zeno",
// description: "Just Another User",
// code: "code",
// avatar: base64UrlEncode(
// File("/home/omegaui/Downloads/icons8-kawaii-shellfish-96.png")
// .readAsBytesSync()))
// .connect("127.0.0.1", 8080, (p0) {});
// Client(
// id: "_mike",
// description: "Just Another User",
// code: "code",
// avatar: base64UrlEncode(
// File("/home/omegaui/Downloads/icons8-markdown-100.png")
// .readAsBytesSync()))
// .connect("127.0.0.1", 8080, (p0) {});
// Client(
// id: "pluto",
// description: "Just Another User",
// code: "code",
// avatar: base64UrlEncode(
// File("/home/omegaui/Downloads/icons8-kawaii-shellfish-96.png")
// .readAsBytesSync()))
// .connect("127.0.0.1", 8080, (p0) {});
//
// Client(
// id: "john",
// description: "Just Another User",
// code: "code",
// avatar: base64UrlEncode(
// File("/home/omegaui/Downloads/icons8-kawaii-shellfish-96.png")
// .readAsBytesSync()))
// .connect("127.0.0.1", 8080, (p0) {});

// var client = Client(
// id: "blaze",
Expand Down
15 changes: 3 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void push(Widget? screen) {
}

void pop() {
contentPaneKey.currentState?.pop();
contentPaneKey.currentState?.changeTo(const HomeScreen());
}

void main() async {
Expand All @@ -31,8 +31,8 @@ void main() async {
runApp(const App());

doWhenWindowReady(() {
appWindow.minSize = const Size(1200, 850);
appWindow.size = const Size(1200, 850);
appWindow.minSize = const Size(1200, 900);
appWindow.size = const Size(1200, 900);
appWindow.alignment = Alignment.center;
appWindow.show();
});
Expand Down Expand Up @@ -82,30 +82,21 @@ class ContentPane extends StatefulWidget {

class ContentPaneState extends State<ContentPane> {
Widget? content;
List<Widget> contents = [];

@override
void initState() {
if (widget.content != null) {
content = widget.content;
contents.add(content as Widget);
}
super.initState();
}

void changeTo(Widget? newContent) {
setState(() {
contents.add(newContent as Widget);
content = newContent;
});
}

void pop() {
setState(() {
content = contents.elementAt(contents.length - 2);
});
}

@override
Widget build(BuildContext context) {
return AnimatedSwitcher(
Expand Down
46 changes: 46 additions & 0 deletions lib/ui/screens/chat_room/controls/chat_components/point_blink.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter/material.dart';

class PointBlink extends StatefulWidget {
const PointBlink({super.key});

@override
State<PointBlink> createState() => _PointBlinkState();
}

class _PointBlinkState extends State<PointBlink>
with SingleTickerProviderStateMixin<PointBlink> {
late AnimationController controller;

@override
void initState() {
super.initState();
controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 1),
);
controller.forward();
controller.repeat();
}

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: controller,
builder: (context, child) {
return Container(
width: 20 * controller.value,
height: 20,
decoration: const BoxDecoration(
color: Colors.greenAccent,
),
);
},
);
}
}
8 changes: 8 additions & 0 deletions lib/ui/screens/chat_room/user_tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:chat_desk/core/io/app_manager.dart';
import 'package:chat_desk/io/server_handler.dart';
import 'package:chat_desk/ui/screens/chat_room/chat_area.dart';
import 'package:chat_desk/ui/screens/chat_room/chat_room.dart';
import 'package:chat_desk/ui/screens/chat_room/controls/chat_components/point_blink.dart';
import 'package:chat_desk/ui/screens/home_screen.dart';
import 'package:chat_desk/ui/utils.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -204,6 +205,13 @@ class UserTabState extends State<UserTab> {
),
],
),
const Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 18.0),
// child: PointBlink(),
))),
],
),
),
Expand Down

0 comments on commit 22a0afd

Please sign in to comment.