mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 18:57:05 +08:00
refactor: replace TextButton with HomeScreenTaskButton in home page
This commit is contained in:
@@ -4,13 +4,15 @@ class DashbotWindowModel {
|
|||||||
final double right;
|
final double right;
|
||||||
final double bottom;
|
final double bottom;
|
||||||
final bool isActive;
|
final bool isActive;
|
||||||
|
final bool isPopped;
|
||||||
|
|
||||||
const DashbotWindowModel({
|
const DashbotWindowModel({
|
||||||
this.width = 350,
|
this.width = 375,
|
||||||
this.height = 450,
|
this.height = 460,
|
||||||
this.right = 50,
|
this.right = 50,
|
||||||
this.bottom = 100,
|
this.bottom = 100,
|
||||||
this.isActive = false,
|
this.isActive = false,
|
||||||
|
this.isPopped = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
DashbotWindowModel copyWith({
|
DashbotWindowModel copyWith({
|
||||||
@@ -19,6 +21,7 @@ class DashbotWindowModel {
|
|||||||
double? right,
|
double? right,
|
||||||
double? bottom,
|
double? bottom,
|
||||||
bool? isActive,
|
bool? isActive,
|
||||||
|
bool? isPopped,
|
||||||
}) {
|
}) {
|
||||||
return DashbotWindowModel(
|
return DashbotWindowModel(
|
||||||
width: width ?? this.width,
|
width: width ?? this.width,
|
||||||
@@ -26,6 +29,7 @@ class DashbotWindowModel {
|
|||||||
right: right ?? this.right,
|
right: right ?? this.right,
|
||||||
bottom: bottom ?? this.bottom,
|
bottom: bottom ?? this.bottom,
|
||||||
isActive: isActive ?? this.isActive,
|
isActive: isActive ?? this.isActive,
|
||||||
|
isPopped: isPopped ?? this.isPopped,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:apidash_design_system/tokens/measurements.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import '../../../chat/models/chat_models.dart';
|
import '../../../chat/models/chat_models.dart';
|
||||||
|
import '../widgets/home_screen_task_button.dart';
|
||||||
|
|
||||||
class DashbotHomePage extends ConsumerStatefulWidget {
|
class DashbotHomePage extends ConsumerStatefulWidget {
|
||||||
const DashbotHomePage({super.key});
|
const DashbotHomePage({super.key});
|
||||||
@@ -48,97 +49,49 @@ class _DashbotHomePageState extends ConsumerState<DashbotHomePage> {
|
|||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
// TextButton(
|
HomeScreenTaskButton(
|
||||||
// onPressed: () {
|
label: "🤖 Chat with Dashbot",
|
||||||
// Navigator.of(context).pushNamed(
|
onPressed: () {
|
||||||
// DashbotRoutes.dashbotChat,
|
Navigator.of(context).pushNamed(
|
||||||
// );
|
DashbotRoutes.dashbotChat,
|
||||||
// },
|
);
|
||||||
// style: TextButton.styleFrom(
|
},
|
||||||
// side: BorderSide(
|
),
|
||||||
// color: Theme.of(context).colorScheme.primary,
|
HomeScreenTaskButton(
|
||||||
// ),
|
label: "🔎 Explain me this response",
|
||||||
// padding: const EdgeInsets.symmetric(
|
|
||||||
// vertical: 0,
|
|
||||||
// horizontal: 16,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// child: const Text("🤖 Chat with Dashbot"),
|
|
||||||
// ),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
DashbotRoutes.dashbotChat,
|
DashbotRoutes.dashbotChat,
|
||||||
arguments: ChatMessageType.explainResponse,
|
arguments: ChatMessageType.explainResponse,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
|
||||||
side: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
HomeScreenTaskButton(
|
||||||
vertical: 0,
|
label: "🐞 Help me debug this error",
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text("🔎 Explain me this response"),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
DashbotRoutes.dashbotChat,
|
DashbotRoutes.dashbotChat,
|
||||||
arguments: ChatMessageType.debugError,
|
arguments: ChatMessageType.debugError,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
|
||||||
side: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
HomeScreenTaskButton(
|
||||||
vertical: 0,
|
label: "📄 Generate documentation",
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text("🐞 Help me debug this error"),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
DashbotRoutes.dashbotChat,
|
DashbotRoutes.dashbotChat,
|
||||||
arguments: ChatMessageType.general,
|
arguments: ChatMessageType.general,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
|
||||||
side: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
HomeScreenTaskButton(
|
||||||
vertical: 0,
|
label: "📝 Generate Tests",
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text(
|
|
||||||
"📄 Generate documentation",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
DashbotRoutes.dashbotChat,
|
DashbotRoutes.dashbotChat,
|
||||||
arguments: ChatMessageType.generateTest,
|
arguments: ChatMessageType.generateTest,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
|
||||||
side: BorderSide(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 0,
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Text("📝 Generate Tests"),
|
|
||||||
),
|
),
|
||||||
if (currentRequest?.httpResponseModel?.statusCode != null &&
|
if (currentRequest?.httpResponseModel?.statusCode != null &&
|
||||||
currentRequest?.httpResponseModel?.statusCode == 200) ...[
|
currentRequest?.httpResponseModel?.statusCode == 200) ...[
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class HomeScreenTaskButton extends StatelessWidget {
|
||||||
|
const HomeScreenTaskButton({
|
||||||
|
super.key,
|
||||||
|
required this.label,
|
||||||
|
required this.onPressed,
|
||||||
|
this.textAlign = TextAlign.center,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String label;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
final TextAlign textAlign;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TextButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
side: BorderSide(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 0,
|
||||||
|
horizontal: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
textAlign: textAlign,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user