Socialify

Folder ..

Viewing repos.dart
157 lines (150 loc) • 5.5 KB

  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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:macos_ui/macos_ui.dart';

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

  @override
  State<RepositoriesPage> createState() => _RepositoriesPageState();
}

class _RepositoriesPageState extends State<RepositoriesPage> {
  @override
  Widget build(BuildContext context) {
    return Builder(builder: (context) {
      return MacosScaffold(
        toolBar: ToolBar(
          title: const Text('Repositories'),
          leading: MacosTooltip(
              message: 'Toggle Sidebar',
              child: MacosIconButton(
                icon: MacosIcon(
                  CupertinoIcons.sidebar_left,
                  color: MacosTheme.brightnessOf(context).resolve(
                    const Color.fromRGBO(0, 0, 0, 0.5),
                    const Color.fromRGBO(255, 255, 255, 0.5),
                  ),
                  size: 20.0,
                ),
                boxConstraints: const BoxConstraints(
                  minHeight: 20,
                  minWidth: 20,
                  maxWidth: 48,
                  maxHeight: 38,
                ),
                onPressed: () => MacosWindowScope.of(context).toggleSidebar(),
              )),
          actions: [
            ToolBarPullDownButton(
              label: 'New',
              icon: CupertinoIcons.add,
              items: [
                MacosPulldownMenuItem(
                  label: 'New Repository',
                  title: const Text("New Repository"),
                  onTap: () => debugPrint("Creating new repository"),
                ),
                MacosPulldownMenuItem(
                  label: 'New Gist',
                  title: const Text("New Gist"),
                  onTap: () => debugPrint("Creating new gist"),
                ),
                MacosPulldownMenuItem(
                  label: 'New Organization',
                  title: const Text("New Organization"),
                  onTap: () => debugPrint("Creating new organization"),
                ),
              ],
            )
          ],
        ),
        children: [
          ContentArea(builder: (context, scrollController) {
            return const RepositoriesList();
          }),
        ],
      );
    });
  }
}

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

  @override
  State<RepositoriesList> createState() => _RepositoriesListState();
}

class _RepositoriesListState extends State<RepositoriesList> {
  int _selectedIndex = 0;
  var _currentContent = "This is some sample content";

  @override
  Widget build(BuildContext context) {
    final isDarkMode = MacosTheme.brightnessOf(context) == Brightness.dark;
    return Row(
      children: <Widget>[
        Container(
          decoration: BoxDecoration(
            border: isDarkMode
                ? const Border(
                    right: BorderSide(color: Color.fromRGBO(56, 56, 56, 1)))
                : const Border(
                    right: BorderSide(color: Color.fromRGBO(224, 224, 224, 1))),
          ),
          child: Padding(
            padding: const EdgeInsets.all(8),
            child: SizedBox(
              width: 300,
              child: ListView.builder(
                itemCount: 15,
                itemBuilder: (context, index) {
                  return GestureDetector(
                    onTap: () {
                      setState(() {
                        _selectedIndex = index;
                        _currentContent = "This is repository ${index + 1}";
                      });
                    },
                    child: Card(
                      elevation: 0,
                      color: _selectedIndex == index
                          ? const Color.fromRGBO(52, 120, 246, 1)
                          : Colors.transparent,
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: SizedBox(
                            width: 300,
                            child: MacosListTile(
                              leading: Icon(
                                CupertinoIcons.folder,
                                color: _selectedIndex == index
                                    ? Colors.white
                                    : Colors.blue,
                              ),
                              title: Text("Repository ${index + 1}",
                                  style: isDarkMode || _selectedIndex == index
                                      ? const TextStyle(color: Colors.white)
                                      : const TextStyle(color: Colors.black)),
                              subtitle: Text(
                                  "Longer description of repository $index. Adding more and more text to see how the multiline text will look.",
                                  style: isDarkMode || _selectedIndex == index
                                      ? const TextStyle(color: Colors.white70)
                                      : const TextStyle(color: Colors.black54)),
                            )),
                      ),
                    ),
                  );
                },
              ),
            ),
          ),
        ),
        Expanded(
          child: SingleChildScrollView(
            controller: ScrollController(),
            child: Column(
              children: <Widget>[
                Text(_currentContent),
              ],
            ),
          ),
        )
      ],
    );
  }
}