Skip to content

Commit 4a2fc2d

Browse files
committed
first commit
0 parents  commit 4a2fc2d

30 files changed

+1751
-0
lines changed

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
42+
43+
# Android Studio will place build artifacts here
44+
/android/app/debug
45+
/android/app/profile
46+
/android/app/release

.metadata

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled and should not be manually edited.
5+
6+
version:
7+
revision: 5f105a6ca7a5ac7b8bc9b241f4c2d86f4188cf5c
8+
channel: stable
9+
10+
project_type: app

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cSpell.words": ["Cupertino"]
3+
}

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# todo_client
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13+
14+
For help getting started with Flutter, view our
15+
[online documentation](https://flutter.dev/docs), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

lib/components/CursorPointer.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'package:flutter/cupertino.dart';
2+
3+
Widget baseCursorPointer(Widget child,
4+
{MouseCursor cursor = SystemMouseCursors.click}) {
5+
return MouseRegion(child: child, cursor: cursor);
6+
}

lib/main.dart

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
import 'package:flutter/cupertino.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:bitsdojo_window/bitsdojo_window.dart';
4+
import 'package:flutter_bloc/flutter_bloc.dart';
5+
import 'package:todo_client/state/mainStore.dart';
6+
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
7+
8+
void main() {
9+
runApp(const MyApp());
10+
doWhenWindowReady(() {
11+
final win = appWindow;
12+
const initialSize = Size(1050, 700);
13+
win.minSize = initialSize;
14+
win.size = initialSize;
15+
win.alignment = Alignment.center;
16+
win.title = "Custom window with Flutter";
17+
win.show();
18+
});
19+
}
20+
21+
const borderColor = Color(0xFF805306);
22+
23+
class MyApp extends StatelessWidget {
24+
const MyApp({Key? key}) : super(key: key);
25+
@override
26+
Widget build(BuildContext context) {
27+
return BlocProvider(
28+
create: (_) => MainStore(),
29+
child: BlocBuilder<MainStore, MainState>(builder: (context, state) {
30+
return MaterialApp(
31+
debugShowCheckedModeBanner: false,
32+
theme: state.currentTheme,
33+
home: Scaffold(
34+
body: WindowBorder(
35+
color: borderColor,
36+
width: 1,
37+
child: Column(
38+
children: [
39+
const TopBar(),
40+
Text(state.theme.toString()),
41+
ElevatedButton(
42+
onPressed: () {
43+
context
44+
.read<MainStore>()
45+
.changeTheme(BaseThemeMode.blue);
46+
},
47+
child: const Text('change theme')),
48+
IconButton(
49+
padding: const EdgeInsets.all(0),
50+
hoverColor: Colors.transparent,
51+
splashColor: Colors.transparent,
52+
icon: const Icon(
53+
Icons.arrow_back_ios,
54+
size: 15,
55+
),
56+
onPressed: () {},
57+
),
58+
],
59+
),
60+
),
61+
),
62+
);
63+
}),
64+
);
65+
}
66+
}
67+
68+
class TopBar extends StatelessWidget {
69+
const TopBar({Key? key}) : super(key: key);
70+
@override
71+
Widget build(BuildContext context) {
72+
return LayoutBuilder(
73+
builder: ((BuildContext context, BoxConstraints boxConstraints) {
74+
return Container(
75+
width: boxConstraints.maxWidth,
76+
height: 60,
77+
color: Theme.of(context).primaryColor,
78+
child: MoveWindow(
79+
child: Row(
80+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
81+
children: [
82+
DefaultTextStyle(
83+
style: const TextStyle(color: Colors.white),
84+
child: Padding(
85+
padding: const EdgeInsets.symmetric(horizontal: 20),
86+
child: Row(
87+
crossAxisAlignment: CrossAxisAlignment.center,
88+
children: [
89+
const Text(
90+
'todoList',
91+
style: TextStyle(fontSize: 18),
92+
),
93+
const SizedBox(
94+
width: 100,
95+
),
96+
CupertinoButton(
97+
child: const Icon(Icons.arrow_back_ios,
98+
size: 15, color: Colors.white),
99+
onPressed: () {}),
100+
CupertinoButton(
101+
padding: const EdgeInsets.all(0),
102+
child: const Icon(Icons.arrow_forward_ios,
103+
size: 15, color: Colors.white),
104+
onPressed: () {})
105+
],
106+
),
107+
)),
108+
Row(
109+
crossAxisAlignment: CrossAxisAlignment.center,
110+
children: [
111+
MouseRegion(
112+
cursor: SystemMouseCursors.click,
113+
child: CupertinoButton(
114+
padding: const EdgeInsets.all(0),
115+
child: const FaIcon(
116+
FontAwesomeIcons.shirt,
117+
color: Colors.white,
118+
size: 14,
119+
),
120+
onPressed: () {}),
121+
),
122+
const WindowButtons(),
123+
],
124+
)
125+
],
126+
)),
127+
);
128+
}));
129+
}
130+
}
131+
132+
final buttonColors = WindowButtonColors(
133+
iconNormal: Colors.white,
134+
mouseOver: Colors.transparent,
135+
mouseDown: Colors.transparent,
136+
);
137+
138+
class WindowButtons extends StatefulWidget {
139+
const WindowButtons({Key? key}) : super(key: key);
140+
141+
@override
142+
_WindowButtonsState createState() => _WindowButtonsState();
143+
}
144+
145+
class _WindowButtonsState extends State<WindowButtons> {
146+
void maximizeOrRestore() {
147+
setState(() {
148+
appWindow.maximizeOrRestore();
149+
});
150+
}
151+
152+
@override
153+
Widget build(BuildContext context) {
154+
return Row(
155+
crossAxisAlignment: CrossAxisAlignment.center,
156+
children: [
157+
MinimizeWindowButton(colors: buttonColors),
158+
appWindow.isMaximized
159+
? RestoreWindowButton(
160+
colors: buttonColors,
161+
onPressed: maximizeOrRestore,
162+
)
163+
: MaximizeWindowButton(
164+
colors: buttonColors,
165+
onPressed: maximizeOrRestore,
166+
),
167+
CloseWindowButton(colors: buttonColors),
168+
],
169+
);
170+
}
171+
}

lib/state/mainStore.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_bloc/flutter_bloc.dart';
3+
import 'package:todo_client/state/theme_data.dart';
4+
5+
enum BaseThemeMode { dark, red, pink, blue, green, orange }
6+
7+
class MainStore extends Cubit<MainState> {
8+
MainStore() : super(MainState());
9+
10+
void changeTheme(BaseThemeMode theme) {
11+
state.theme = theme;
12+
emit(state);
13+
}
14+
}
15+
16+
class MainState {
17+
BaseThemeMode theme = BaseThemeMode.red;
18+
bool isLogin = false;
19+
List playList = [];
20+
21+
ThemeData get currentTheme => baseThemeData[theme.toString()] as ThemeData;
22+
}

lib/state/theme_data.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:flutter/material.dart';
2+
3+
Map<String, ThemeData> baseThemeData = {
4+
'BaseThemeMode.red': ThemeData(primaryColor: Colors.red),
5+
'BaseThemeMode.dark': ThemeData(primaryColor: Colors.black),
6+
'BaseThemeMode.pink': ThemeData(primaryColor: Colors.pink),
7+
'BaseThemeMode.blue': ThemeData(primaryColor: Colors.blue),
8+
'BaseThemeMode.green': ThemeData(primaryColor: Colors.green),
9+
'BaseThemeMode.orange': ThemeData(primaryColor: Colors.orange),
10+
};

0 commit comments

Comments
 (0)