Jetnews is a sample news reading app, built with Jetpack Compose. The goal of the sample is to showcase the current UI capabilities of Compose.
To try out this sample app, you need to use the Canary version of Android Studio 4.0, and import the project from the Android Samples following the steps here.
Compose is not available in earlier versions of Android Studio and downloading this github repo directly and opening it will most likely result in build errors.
This sample contains three screens: a list of articles, a detail page for articles, and a page to subscribe to topics of interest. The navigation from the the list of articles to the interests screen uses a navigation drawer.
Package com.example.jetnews.ui
JetnewsApp.kt
arranges the different screens in the NavDrawerLayout
. It also implements a simple
navigation pattern.
Package com.example.jetnews.ui.home
This screen shows how to create different custom Composable functions and combine them in a list that scrolls vertically and horizontally.
See how to :
- use Rows and Columns to arrange the contents of the UI
- add an AppBar
- use Material Typography and opacity to style the text
- use Shape to round the corners of the images
- use Elevation to make the Cards stand out from the background
Package com.example.jetnews.ui.article
This screen dives into the Text API, showing how to use different fonts than the ones defined in
Typograhy
. It also adds a bottom appbar, with custom actions.
Package com.example.jetnews.ui.interests
This screens shows how to use Tabs and switch content depending on the selected tab. It
also includes a custom checkbox button, SelectTopicButton
that uses a Toggleable
composable function to provide
the on/off behaviour and semantics, while drawing a custom UI. The UI of the button is partly
drawn with low-level primitives and partly overlaying images. See also how to visualize
on and off, light and dark version in the Android Studio Preview.
The data in the sample is static, held in the com.example.jetnews.data
package.
Copyright 2019 Google, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.