Measurement of the charged-hadron spectra and nuclear modification factor in lead--lead collisions with the ATLAS detector