Léo Salé преди 3 години
родител
ревизия
1cf139132c
променени са 1 файла, в които са добавени 33 реда и са изтрити 21 реда
  1. 33 21
      app/lib/friends/friends_page.dart

+ 33 - 21
app/lib/friends/friends_page.dart

@@ -10,34 +10,46 @@ class FriendsPage extends StatefulWidget {
 }
 
 class _FriendsPageState extends State<FriendsPage> {
-  int _selectedIndex = 0;
-
   static const List<Widget> _widgets = [
     FriendsList(),
     Requests(),
   ];
 
-  void _onItemTapped(int index) {
-    setState(() {
-      _selectedIndex = index;
-    });
-  }
-
   @override
   Widget build(BuildContext context) {
-    return Scaffold(
-        bottomNavigationBar: BottomNavigationBar(
-          items: const [
-            BottomNavigationBarItem(icon: Icon(Icons.people), label: 'Friends'),
-            BottomNavigationBarItem(icon: Icon(Icons.notifications), label: 'Requests'),
-          ],
-          currentIndex: _selectedIndex,
-          onTap: _onItemTapped,
+    return DefaultTabController(
+      length: 2,
+      child: Scaffold(
+        appBar: AppBar(
+          automaticallyImplyLeading: false,
+          bottom: TabBar(
+            tabs: [
+              Tab(
+                child: Column(
+                  children: const [
+                    Icon(Icons.people),
+                    Text("Friends"),
+                  ],
+                ),
+              ),
+              Tab(
+                child: Column(
+                  children: const [
+                    Icon(Icons.notifications),
+                    Text("Requests"),
+                  ],
+                ),
+              ),
+            ],
+          ),
+        ),
+        body: const Center(
+          child: Padding(
+            padding: EdgeInsets.all(32.0),
+            child: TabBarView(children: _widgets),
+          ),
         ),
-        body: Center(
-            child: Padding(
-          padding: const EdgeInsets.all(32.0),
-          child: _widgets[_selectedIndex],
-        )));
+      ),
+    );
   }
 }