use crate::ui::prelude::*;

pub( crate ) fn view_apps( state: &State ) -> Element<Msg>
{
	let mut col = column::<Msg>()
		.padding( 24.0 )
		.spacing( 4.0 )
		.push( header( &tr!( "home.apps" ) ) );

	if state.installed_apps.is_empty()
	{
		col = col.push( t_sec!( tr!( "apps.loading" ) ).size( 14.0 ) );
	}
	else
	{
		let mut app_col = column::<Msg>().spacing( 0.0 );
		for app in &state.installed_apps
		{
			let exec = app.exec.clone();
			let it = with_chevron( list_item( &app.name ).on_press( Msg::LaunchApp( exec ) ) );
			app_col = app_col.push( it );
		}
		col = col.push( scroll( app_col ) );
	}

	col.push( spacer() ).into()
}
