aboutsummaryrefslogtreecommitdiff
path: root/frontend/lib/views/side_bar/side_bar_view.dart
blob: 7f224ca4119e213bc8205f206773c2f64e6ecfea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import 'package:auto_gpt_flutter_client/viewmodels/settings_viewmodel.dart';
import 'package:auto_gpt_flutter_client/viewmodels/skill_tree_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

class SideBarView extends StatelessWidget {
  final ValueNotifier<String> selectedViewNotifier;

  const SideBarView({super.key, required this.selectedViewNotifier});

  // Function to launch the URL
  void _launchURL(String urlString) async {
    var url = Uri.parse(urlString);
    if (await canLaunchUrl(url)) {
      await launchUrl(url);
    } else {
      throw 'Could not launch $url';
    }
  }

  @override
  Widget build(BuildContext context) {
    // TODO: should we pass this in as a dependency?
    final skillTreeViewModel =
        Provider.of<SkillTreeViewModel>(context, listen: true);
    return Material(
      child: ValueListenableBuilder(
          valueListenable: selectedViewNotifier,
          builder: (context, String selectedView, _) {
            return SizedBox(
              width: 60,
              child: Column(
                children: [
                  Column(
                    children: [
                      IconButton(
                        splashRadius: 0.1,
                        color: selectedView == 'TaskView'
                            ? Colors.blue
                            : Colors.black,
                        icon: const Icon(Icons.chat),
                        onPressed: skillTreeViewModel.isBenchmarkRunning
                            ? null
                            : () => selectedViewNotifier.value = 'TaskView',
                      ),
                      if (Provider.of<SettingsViewModel>(context, listen: true)
                          .isDeveloperModeEnabled)
                        IconButton(
                          splashRadius: 0.1,
                          color: selectedView == 'SkillTreeView'
                              ? Colors.blue
                              : Colors.black,
                          icon: const Icon(Icons.emoji_events),
                          onPressed: skillTreeViewModel.isBenchmarkRunning
                              ? null
                              : () =>
                                  selectedViewNotifier.value = 'SkillTreeView',
                        ),
                      IconButton(
                        splashRadius: 0.1,
                        color: selectedView == 'SettingsView'
                            ? Colors.blue
                            : Colors.black,
                        icon: const Icon(Icons.settings),
                        onPressed: () =>
                            selectedViewNotifier.value = 'SettingsView',
                      ),
                    ],
                  ),
                  const Spacer(),
                  Column(
                    children: [
                      IconButton(
                        splashRadius: 0.1,
                        iconSize: 25,
                        icon: Icon(Icons.book, color: Color.fromRGBO(50, 120, 123, 1)),
                        onPressed: () =>
                            _launchURL('https://aiedge.medium.com/autogpt-forge-e3de53cc58ec'),
                        tooltip: 'Learn how to build your own Agent',
                      ),
                      IconButton(
                        splashRadius: 0.1,
                        iconSize: 33,
                        icon: Image.asset('assets/images/autogpt_logo.png'),
                        onPressed: () =>
                            _launchURL('https://leaderboard.agpt.co'),
                        tooltip: 'Check out the leaderboard',
                      ),
                      IconButton(
                        splashRadius: 0.1,
                        iconSize: 25,
                        icon: Image.asset('assets/images/discord_logo.png'),
                        onPressed: () =>
                            _launchURL('https://discord.gg/autogpt'),
                        tooltip: 'Join our Discord',
                      ),
                      const SizedBox(height: 6),
                      IconButton(
                        splashRadius: 0.1,
                        iconSize: 15,
                        icon: Image.asset('assets/images/twitter_logo.png'),
                        onPressed: () =>
                            _launchURL('https://twitter.com/Auto_GPT'),
                        tooltip: 'Follow us on Twitter',
                      ),
                      const SizedBox(height: 8),
                    ],
                  ),
                ],
              ),
            );
          }),
    );
  }
}