Skip to content

Commit

Permalink
Merge pull request #28 from moesaid/stage
Browse files Browse the repository at this point in the history
0.0.6
  • Loading branch information
moesaid authored Mar 1, 2024
2 parents 895e61b + ba1a24a commit fe368e4
Show file tree
Hide file tree
Showing 14 changed files with 361 additions and 86 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/windows_ci_cd.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
workflow_dispatch
# push:
# branches: [main]
# workflow_dispatch
push:
branches: [main]

name: Windows

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutterpp/App/Controllers/Project/Single/project_single_controller.dart';
import 'package:flutterpp/App/Services/Cmd/cmd_init_getx_mvc_services.dart';
import 'package:flutterpp/App/Views/Global/build_overlay.dart';
import 'package:flutterpp/Config/app_print.dart';
import 'package:get/get.dart';

class ProjectSingleConfigController extends GetxController {
Expand All @@ -26,12 +27,17 @@ class ProjectSingleConfigController extends GetxController {

Future<void> startConfig() async {
if (useController.projectLocalPath.isEmpty) return;
await Get.showOverlay(
asyncFunction: () async {
await _cmd.init(useController.projectLocalPath);
await useController.checkIfFlutterPPProject();
},
loadingWidget: const BuildOverlay(),
);

try {
await Get.showOverlay(
asyncFunction: () async {
await _cmd.init(useController.projectLocalPath);
await useController.checkIfFlutterPPProject();
},
loadingWidget: const BuildOverlay(),
);
} catch (e) {
AppPrint.printError('Error starting project config: $e');
}
}
}
51 changes: 43 additions & 8 deletions lib/App/Providers/Cmd/cmd_read_create_dir_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:io';

import 'package:flutterpp/Config/app_print.dart';
import 'package:get/get.dart';
import 'package:process_run/process_run.dart';
import 'package:process_run/cmd_run.dart';

class CmdReadCreateDirProvider {
// list directory
Expand All @@ -12,14 +12,28 @@ class CmdReadCreateDirProvider {
String? option,
}) async {
try {
String command = GetPlatform.isWindows ? 'dir' : 'ls';
Directory directory = Directory(path);

var result = await runExecutableArguments(command, [option ?? '', path]);
// check if directory exist
if (!await directory.exists()) {
AppPrint.print('❌directory not exist');
return null;
}

List<FileSystemEntity> list = directory.listSync(recursive: false);

List<String> res = [];
for (var item in result.outLines) {
if (item == '$path:') continue;
res.add(item);
for (var item in list) {
String name = '';

// get the last part of the path
if (GetPlatform.isWindows) {
name = item.path.split(r'\').last;
} else {
name = item.path.split('/').last;
}

res.add(name);
}

return res;
Expand All @@ -31,7 +45,18 @@ class CmdReadCreateDirProvider {

Future<void> createDirectory(String path) async {
try {
ProcessResult res = await runExecutableArguments('mkdir', ['-p', path]);
//ProcessResult res = = await runExecutableArguments('mkdir', ['-p', path]);

ProcessCmd cmd = ProcessCmd(
'mkdir',
[
GetPlatform.isWindows ? '' : '-p',
path,
],
runInShell: true,
);
ProcessResult res = await runCmd(cmd);

AppPrint.print('mkdir: ${res.stdout}');
} catch (e) {
AppPrint.print('Error creating directory: $e');
Expand All @@ -43,7 +68,17 @@ class CmdReadCreateDirProvider {
String command = GetPlatform.isWindows ? 'type nul' : 'touch';

try {
await runExecutableArguments('touch', [path]);
// await runExecutableArguments('touch', [path]);

ProcessCmd cmd = ProcessCmd(
command,
[path],
runInShell: true,
);

ProcessResult res = await runCmd(cmd);

AppPrint.print('touch: ${res.stdout}');
} catch (e) {
AppPrint.print('Error creating file: $e');
}
Expand Down
10 changes: 7 additions & 3 deletions lib/App/Providers/Device/file_maneger_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,13 @@ class FileManegerProvider {
return;
}

// open folder

ProcessResult res = await Process.run(command, [location]);
// open directory
ProcessResult res = await Process.run(
command,
[location],
workingDirectory: location,
runInShell: true,
);

AppPrint.print(res.stdout);
},
Expand Down
15 changes: 11 additions & 4 deletions lib/App/Services/Cmd/cmd_read_create_dir_services.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutterpp/App/Providers/Cmd/cmd_read_create_dir_provider.dart';
import 'package:flutterpp/Config/app_print.dart';
import 'package:json2yaml/json2yaml.dart';

class CmdReadCreateDirServices {
Expand All @@ -8,12 +9,18 @@ class CmdReadCreateDirServices {
Future<bool> isFlutterPPProject(String path) async {
List<String>? res = await _dirProvider.listDirectory(path);

// check if theres a .flutterpp file
if (res != null) {
return res.contains('flutterpp.yaml');
// if res is null
if (res == null) {
AppPrint.print('res is null');
return false;
}

for (var item in res) {
AppPrint.print('item: $item');
}

return false;
// check if theres a .flutterpp file
return res.contains('flutterpp.yaml');
}

// read all files in a directory
Expand Down
153 changes: 111 additions & 42 deletions lib/App/Views/Global/build_appbar.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutterpp/App/Views/Global/build_windows_buttons.dart';
import 'package:get/get.dart';
import 'package:window_manager/window_manager.dart';

class BuildAppBar extends StatelessWidget implements PreferredSizeWidget {
final bool? hasBackButton;
Expand All @@ -16,63 +18,130 @@ class BuildAppBar extends StatelessWidget implements PreferredSizeWidget {
@override
Size get preferredSize => const Size.fromHeight(30);

@override
Widget build(BuildContext context) {
if (GetPlatform.isWindows) {
return DragToMoveArea(
child: _BuildAppBar(
preferredSize: preferredSize,
hasBackButton: hasBackButton,
onBack: onBack,
title: title,
),
);
}

return _BuildAppBar(
preferredSize: preferredSize,
hasBackButton: hasBackButton,
onBack: onBack,
title: title,
);
}
}

class _BuildAppBar extends StatelessWidget {
const _BuildAppBar({
super.key,
required this.preferredSize,
required this.hasBackButton,
required this.onBack,
required this.title,
});

final Size preferredSize;
final bool? hasBackButton;
final VoidCallback? onBack;
final String? title;

@override
Widget build(BuildContext context) {
return AppBar(
toolbarHeight: preferredSize.height,
title: SizedBox(
title: const SizedBox(
width: double.infinity,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
),
leading: const SizedBox.shrink(),
flexibleSpace: Container(
height: preferredSize.height,
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey, width: 0.2),
),
),
child: Stack(
alignment: Alignment.center,
children: [
if (hasBackButton != null && hasBackButton!)
SizedBox(
height: preferredSize.height,
width: 0,
child: VerticalDivider(color: Colors.grey.withOpacity(0.35)),
),
if (hasBackButton != null && hasBackButton!)
InkWell(
onTap: onBack ?? () => Get.back(),
child: Container(
height: preferredSize.height,
width: preferredSize.height,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
),
child: Icon(
Icons.arrow_back,
color: Get.theme.colorScheme.secondary,
size: 15,
),
),
Positioned(
left: GetPlatform.isWindows ? 0 : 70,
child: BuildLeading(
hasBackButton: hasBackButton,
preferredSize: preferredSize,
onBack: onBack,
),
SizedBox(
height: preferredSize.height,
width: 0,
child: VerticalDivider(color: Colors.grey.withOpacity(0.35)),
),
Expanded(
child: Center(
child: Text(
title ?? 'title',
style: Get.textTheme.bodySmall?.copyWith(
fontStyle: FontStyle.normal,
),
),
Text(
title ?? 'title',
style: Get.textTheme.bodySmall?.copyWith(
fontStyle: FontStyle.normal,
),
),
if (GetPlatform.isWindows)
const Positioned(right: 0, child: BuildWindowsButtons())
],
),
),
leading: const SizedBox.shrink(),
flexibleSpace: Container(
decoration: const BoxDecoration(
border: Border(
bottom: BorderSide(color: Colors.grey, width: 0.2),
);
}
}

class BuildLeading extends StatelessWidget {
const BuildLeading({
super.key,
required this.hasBackButton,
required this.preferredSize,
required this.onBack,
});

final bool? hasBackButton;
final Size preferredSize;
final VoidCallback? onBack;

@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (hasBackButton != null && hasBackButton! & GetPlatform.isMacOS)
SizedBox(
height: preferredSize.height,
width: 0,
child: VerticalDivider(color: Colors.grey.withOpacity(0.35)),
),
if (hasBackButton != null && hasBackButton!)
InkWell(
onTap: onBack ?? () => Get.back(),
child: Container(
height: preferredSize.height,
width: preferredSize.height,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
),
child: Icon(
Icons.arrow_back,
color: Get.theme.colorScheme.secondary,
size: 15,
),
),
),
SizedBox(
height: preferredSize.height,
width: 0,
child: VerticalDivider(
color: Colors.grey.withOpacity(0.35),
),
),
),
],
);
}
}
43 changes: 43 additions & 0 deletions lib/App/Views/Global/build_appbar_platform_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:heroicons/heroicons.dart';

class BuildAppbarPlatformButton extends StatelessWidget {
final bool hover;
final double size;
final VoidCallback? onTap;
final Color beforeHoverColor, afterHoverColor;
final HeroIcons icon;
const BuildAppbarPlatformButton({
super.key,
required this.hover,
required this.size,
this.onTap,
required this.beforeHoverColor,
required this.afterHoverColor,
required this.icon,
});

@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: AnimatedContainer(
height: size,
width: size,
duration: const Duration(milliseconds: 100),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: hover ? afterHoverColor : beforeHoverColor,
),
child: Visibility(
visible: hover,
child: HeroIcon(
icon,
size: 10,
color: Colors.black54,
),
),
),
);
}
}
Loading

0 comments on commit fe368e4

Please sign in to comment.